MySQL Forums
Forum List  »  Stored Procedures

about getting the auto increment to work in stored procedure
Posted by: Bob Smith
Date: August 18, 2016 02:40PM

I got my stored procedure to work like this:


DELIMITER go
Create procedure addusers(
Out UserID int(11),
IN FirstName varchar(10),
IN LastName varchar(10),
IN Password varchar(10),
IN EmailAddress varchar(10),
IN HomeAddress varchar(20)
BEGIN
insert into users(

FirstName,
LastName ,
Password ,
EmailAddress,
HomeAddress
)
Values
(
FirstName,
LastName ,
Password ,
EmailAddress ,
HomeAddress
)
set UserID = AUTO_INCREMENT;

End
go
DELIMITER ;

Now when I used call addusers(

'Jamie',
'Smith',
'oreo',
'jamie@gmail.com',
'34 young street'
Note that I didn't include UserId because its auto increment. When I executed I got an error that says:
"Error

SQL query:

call addusers(

'Jamie',
'Smith',
'oreo',
'jamie@gmail.com',
'34 young street')

MySQL said: Documentation
#1318 - Incorrect number of arguments for PROCEDURE JonesCorp.addusers; expected 6, got 5"

I actually want to pass only call addusers(

'Jamie',
'Smith',
'oreo',
'jamie@gmail.com',
'34 young street') without entering the UserID which is auto increment

Options: ReplyQuote


Subject
Views
Written By
Posted
about getting the auto increment to work in stored procedure
5484
August 18, 2016 02:40PM


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.