If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > IF Confusion

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-10-08, 16:26
ajr87 ajr87 is offline
Registered User
 
Join Date: Nov 2006
Posts: 8
IF Confusion

I've written an IF such that...

IF (SELECT SUM(a.balance + a.overdraft) AS "Funds Available"
FROM Account a
WHERE a.accountID = "12345") < 0
THEN
ROLLBACK
ELSE
COMMIT
ENDIF;

But this is wrong and I can't find any comprehensible details online. Can anyone explain how I'm supposed to structure this?
Reply With Quote
  #2 (permalink)  
Old 03-10-08, 18:34
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
is the manual any use?
just a minor point.. you are using INNODB tables I presume
Reply With Quote
  #3 (permalink)  
Old 03-11-08, 05:53
ajr87 ajr87 is offline
Registered User
 
Join Date: Nov 2006
Posts: 8
Yeah, I'd looked at that.

Solved it now. Basically, the code was correct but it has to be in a procedure or function for it to work which wasn't explicitly stated. I had assumed it could be in the general code.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On