MySQL Forums
Forum List  »  Stored Procedures

Simple stored procedure question
Posted by: Les Stockton
Date: January 12, 2006 02:06PM

Forgive me for asking this. I checked the documentation, but was unclear on some of this, so I decided to go try to create this stored procedure, which does work in SQL Server. I'm wanting to do the same thing in MySQL.

Create Proc MyAddRecord ( @TblName varchar(50), @NewIDVal int OUTPUT ) AS EXECUTE('INSERT INTO [' + @TblName +

'] DEFAULT VALUES') SET @NewIDVal = @@IDENTITY


I tried the following:
CREATE PROCEDURE `testcreate`.`MyAddRecord` (@TblName varchar(50),@NewIDVal int OUTPUT)
BEGIN
EXECUTE('INSERT INTO [' + @TblName + '] DEFAULT VALUES')
SET @NewIDVal = @@IDENTITY
END

That didn't work.
So is this a small incompatibility and a slight syntax change, or is this an entirely different thing?
Can someone tell me what the correct Create Procedure would be?

Options: ReplyQuote


Subject
Views
Written By
Posted
Simple stored procedure question
2435
January 12, 2006 02:06PM
1372
January 12, 2006 03:22PM
1431
January 12, 2006 03:37PM
1431
January 12, 2006 03:54PM
1529
January 12, 2006 04:03PM
1544
January 12, 2006 04:19PM
1500
January 12, 2006 04:46PM
1483
January 12, 2006 05:21PM
1390
January 13, 2006 10:29AM
1461
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.