MySQL Forums
Forum List  »  Stored Procedures

Error in IF block
Posted by: Anjanesh Lekshminarayanan
Date: June 20, 2007 06:45AM

Hi

I seem to get an error with this query:

SET @c := (SELECT `id` FROM `tbl1` WHERE `uniqueKEY` = '12345');
IF @c IS NULL THEN
   INSERT INTO `tbl1` VALUES ('', '12345', 'My Name', '26');
   SET @c := LAST_INSERT_ID();
END IF;

#1064 - 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 'IF @c IS NULL THEN
   INSERT IGNORE INTO `tbl1` VALUES ('', '12345' at line 1

Any idea whats causing the error is ?

Thanks

Options: ReplyQuote


Subject
Views
Written By
Posted
Error in IF block
3325
June 20, 2007 06:45AM
1287
June 20, 2007 07:37AM
1113
June 20, 2007 09:09AM
1139
June 20, 2007 10:02AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.