MySQL Forums :: Stored Procedures :: Simply stored proc works OK but is it correct syntax ?


Advanced Search

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
Simply stored proc works OK but is it correct syntax ? 2496 Russel James 09/17/2016 12:17PM
Re: Simply stored proc works OK but is it correct syntax ? 237 Peter Brawley 09/17/2016 01:12PM
Re: Simply stored proc works OK but is it correct syntax ? 278 Russel James 09/17/2016 02:36PM
Re: Simply stored proc works OK but is it correct syntax ? 262 Peter Brawley 09/17/2016 04:32PM


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.