MySQL Forums
Forum List  »  Stored Procedures

Re: Simply stored proc works OK but is it correct syntax ?
Posted by: Russel James
Date: September 17, 2016 02:36PM

CrewID is a string. But that is really the question. I could not get it to work without the quotes.

Say the crewID was "AB01". I was getting error message 'column "AB01" does not exist'. Once I put the quotes around it in the SET statement, it began to work. I just wasnt sure if there was a better way of doing it.

Looking at the slightly longer query which includes a decimal value (wages)..

SET @crewID = CONCAT('"', p_crewID, '"');
SET @reference = CONCAT('"', p_reference, '"');
SET @wages = CONCAT('"', p_wages, '"'); // decimal value.



SET @s = CONCAT("INSERT INTO ", @wagesYear, "(crewID, reference, wages) VALUES (", @crewID, ",", @reference, ",", @wages, ")");
PREPARE stmt FROM @s;
EXECUTE stmt;

The above sql works as expected but seems quite long winded to me. Perhaps there is a way of bypassing the SET statements altogether and use the parameters (p_values) within the CONCAT statement ??

J

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Simply stored proc works OK but is it correct syntax ?
319
September 17, 2016 02:36PM


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.