MySQL Forums
Forum List  »  Stored Procedures

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

Hi folks,

I have been working on a stored proc. I eventually got it to work correctly but I am not sure if 'my way' of doing it is the correct way.

Here is the sproc:

CREATE DEFINER=`root`@`localhost` PROCEDURE `usp_SettlementWages`(
IN p_crewID varchar(4)
)
BEGIN

/* Get Current Wages Year and Insert into Wages table */
SELECT clYear INTO @wagesYear FROM sysControl;
SET @wagesYear = CONCAT('wages', @wagesYear);


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


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

PREPARE stmt FROM @s;
EXECUTE stmt;

END

Options: ReplyQuote


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


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.