Home » Open Source » MySQL » untill condition is true do (merged) (11g)
untill condition is true do (merged) [message #605818] Wed, 15 January 2014 02:35 Go to next message
kekanap
Messages: 19
Registered: January 2008
Location: Centurion
Junior Member

Hallo Team,

Let me show you my sql statement and explain what i would like to do:

update verify_interbill.mtn_inbound
set charge = round((a.duration/60)*0.13,2)
where anum in (select distinct(anum) from verify_interbill.mtn_outbound)
and bnum in (select distinct(bnum) from verify_interbill.mtn_outbound)
and rate = 0.21;


Let me explain what i would like to do:

I would like to apply the statement above until
(((charge - 84481.35)/84481.35) * 100) =< 5


Regards,
Re: untill do [message #605823 is a reply to message #605818] Wed, 15 January 2014 03:04 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Explain "until".
Post a test case.

Re: untill do [message #605824 is a reply to message #605818] Wed, 15 January 2014 03:05 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
Then do so. If you are unable to, then post a valid test case.


ED: Beaten to it (again) Smile

[Updated on: Wed, 15 January 2014 03:05]

Report message to a moderator

Re: untill do [message #605826 is a reply to message #605818] Wed, 15 January 2014 03:06 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Note that you don't need DISTINCT in IN SELECT clause.

Re: untill do [message #605829 is a reply to message #605818] Wed, 15 January 2014 03:20 Go to previous messageGo to next message
kekanap
Messages: 19
Registered: January 2008
Location: Centurion
Junior Member

Ok i ran my statement:

while 

(((charge - 84481.35)/84481.35) * 100) =< 5 

begin 

update verify_interbill.mtn_inbound 
set charge = round((a.duration/60)*0.13,2) 
where anum in (select distinct(anum) from verify_interbill.mtn_outbound) 
and bnum in (select distinct(bnum) from verify_interbill.mtn_outbound) 
and rate = 0.21;


I am getting errors:

mysql> while  (((charge - 84481.35)/84481.35) * 100) =< 5 begin  update verify_interbill.mtn_inbound set charge = round((duration/60)*0.13,2) where anum in (select distinct(anum) from verify_interbill.mtn_outbound) and bnum in (select distinct(bnum) from verify_interbill.mtn_outbound) and rate = 0.21;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'while  (((charge - 84481.35)/84481.35) * 100) =< 5 begin  update verify_interbil' at line 1
mysql>


Regards,

Pax

Re: untill do [message #605830 is a reply to message #605829] Wed, 15 January 2014 03:23 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
Post a test case. If you don't understand what a test case is, then click on the link that Michel Cadot posted. Read the content, if you still don't understand, post here what it is that you don't understand.

In addition,. why don't you post this on a MySQL forum as that seems to be the technology that you're working with.

[Updated on: Wed, 15 January 2014 03:23]

Report message to a moderator

untill condition is true do [message #605832 is a reply to message #605818] Wed, 15 January 2014 03:28 Go to previous messageGo to next message
kekanap
Messages: 19
Registered: January 2008
Location: Centurion
Junior Member

Hallo Team,

Please help, have a look at my script:

while  (((charge - 84481.35)/84481.35) * 100) =< 5 begin  update verify_interbill.mtn_inbound set charge = round((duration/60)*0.13,2) where anum in (select distinct(anum) from verify_interbill.mtn_outbound) and bnum in (select distinct(bnum) from verify_interbill.mtn_outbound) and rate = 0.21;


I am getting an error:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'while  (((charge - 84481.35)/84481.35) * 100) =< 5 begin  update verify_interbil' at line 1


Regards,

Pax
Re: untill do [message #605833 is a reply to message #605829] Wed, 15 January 2014 03:30 Go to previous message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
mysql>


I move the topic to MySQL forum, this SQL & PL/SQL forum is for Oracle RDBMS SQL.

Previous Topic: MySQL 5.0.0 [2003] vs. MySQL 5.6 [2013] from a SQL and SQL/PSM developer viewpoint
Next Topic: what's 'KEY' in 'SHOW CREATE TABLE'?
Goto Forum:
  


Current Time: Thu Mar 28 15:49:43 CDT 2024