MySQL Forums
Forum List  »  Stored Procedures

Re: Insert Stored Procedure Help.
Posted by: Roland Bouman
Date: November 05, 2005 02:20PM

1) NVarchar is not a mysql datatype (see: http://dev.mysql.com/doc/refman/5.0/en/string-types.html). Use varchar instead, and declare with a character set specification if applicable (http://dev.mysql.com/doc/refman/5.0/en/charset-column.html shows this for columns, variable and parameter declarations adhere to the same syntax)

2) your INSERT statement does not end with a semicolon (;). THe semicolon terminates statements inside stored procedures etc:

INSERT
INTO Campers (FirstName, LastName, UserName, Password)
VALUES (cFirstName, cLastName, cUserName, cPassword)
;

3) You cannot RETURN a value from a procedure. Either declare it as a function:

CREATE function sp_InsertNewCamper
(
in cFirstName NVarChar(30),
in cLastName NVarChar(30),
in cUserName NVarChar(30),
in cPassword NVarChar(30)
)
returns int unsigned
..
..

or declare it with an OUT parameter to return the value:

CREATE procedure sp_InsertNewCamper
(
in cFirstName NVarChar(30),
in cLastName NVarChar(30),
in cUserName NVarChar(30),
in cPassword NVarChar(30),
out iIdentity int unsigned
)
begin
..
set iIdentity := last_insert_id();
end;


4) Im not sure if password is a reserved word. If it is, you may have to quote it using backticks (`):

INSERT
INTO Campers (FirstName, LastName, UserName, `Password`)
VALUES (cFirstName, cLastName, cUserName, cPassword)
;

Options: ReplyQuote


Subject
Views
Written By
Posted
3196
November 04, 2005 02:32PM
Re: Insert Stored Procedure Help.
3293
November 05, 2005 02:20PM


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.