MySQL Forums
Forum List  »  Stored Procedures

Re: Simple stored procedure question
Posted by: Les Stockton
Date: January 12, 2006 03:37PM

What about this:

CREATE PROCEDURE `testcreate`.`MyAddRecord` (IN TblName varchar(50),OUT NewIDVal int)
BEGIN
EXECUTE(CONCAT('INSERT INTO [', TblName ,'] DEFAULT VALUES'));
SET NewIDVal = @@IDENTITY;
END

If I use the CONCAT, do I still have to do a prepare? And If so, is it like:

PREPARE stmt1 FROM CONCAT('INSERT INTO [', TblName ,'] DEFAULT VALUES')

Can I do it that way?

or does it have to be:

PREPARE stmt1 FROM 'INSERT INTO [?] DEFAULT'
SET @a = TblName

EXECUTE stmt1 USING @a

And do I have to declare @a and stmt1?



Edited 1 time(s). Last edit at 01/12/2006 03:38PM by Les Stockton.

Options: ReplyQuote


Subject
Views
Written By
Posted
2449
January 12, 2006 02:06PM
1383
January 12, 2006 03:22PM
Re: Simple stored procedure question
1442
January 12, 2006 03:37PM
1439
January 12, 2006 03:54PM
1536
January 12, 2006 04:03PM
1554
January 12, 2006 04:19PM
1511
January 12, 2006 04:46PM
1489
January 12, 2006 05:21PM
1399
January 13, 2006 10:29AM
1471
January 13, 2006 12:19PM


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.