views:

80

answers:

2

How would this stored procedure look like in MySQL? :

=========================================================================

Create PROCEDURE [dbo].[Customer_Insert]
(
   @CustomerID int = NULL OUTPUT,
   @CustomerRef varchar(25),
   @Name varchar(64) = NULL,
)
AS
SET NOCOUNT ON

INSERT INTO [Customers]
(
 [CustomerRef],
 [Name]
)
VALUES
(
 @CustomerRef,
 @Name  
)

SELECT @CustomerID = SCOPE_IDENTITY();
+1  A: 

Should be pretty straightforward, this should point you in the right direction. I have not executed it myself.

CREATE PROCEDURE Customer_Insert
(OUT CustomerID INT, IN CustomerRef VARCHAR(25), IN Name VARCHAR(64))

BEGIN

INSERT INTO Customers (CustomerRef, Name) VALUES (CustomerRef, Name);
SELECT LAST_INSERT_ID() INTO CustomerID;
END
Cody Caughlan
A: 

Thanks, but i get a error:

Undeclared variable: CustomerID

On the SELECT LAST_INSERT_ID() INTO CustomerID; line...