MySQL Forums
Forum List  »  Stored Procedures

Re: Simply stored proc works OK but is it correct syntax ?
Posted by: Peter Brawley
Date: September 17, 2016 01:12PM

> SET @crewID = CONCAT('"', p_crewID, '"'); // Is this correct ??

Is crewid an int? If so, why quote it!?

> SET @s = CONCAT("INSERT INTO ", @wagesYear, "(crewID) VALUES (", @crewID, ")");

The Insert statemens cites one column to be set, but supplies two values. If the first value, '', is meant as a placeholder for an auto_increment column, it should be NULL and you need to add it at the front of the column list. Or more simply, let MySQL handle it, and lose the '' value.

> PREPARE stmt FROM @s;
> EXECUTE stmt;

Missing DROP PREPARE.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Simply stored proc works OK but is it correct syntax ?
309
September 17, 2016 01:12PM


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.