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


Advanced Search

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 ? 2169 Russel James 09/17/2016 12:17PM
Re: Simply stored proc works OK but is it correct syntax ? 215 Peter Brawley 09/17/2016 01:12PM
Re: Simply stored proc works OK but is it correct syntax ? 255 Russel James 09/17/2016 02:36PM
Re: Simply stored proc works OK but is it correct syntax ? 242 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.