我正在使用带有错误消息的registerusers存储过程,当我执行结果时,我收到一条错误消息:'MySQL说:文档
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near /*declaring local variable*/
declare checkfirstnamecount int;
declare checklastn' at line 10'
这是我的存储过程:
DELIMITER go
Create procedure registerusers(
Out UserID tinyint(11),
IN iFirstName varchar(30),
IN iLastName varchar(30),
IN iPassword varchar(30),
IN iEmailAddress varchar(30),
IN iSalt varchar(40),
IN iRoleID varchar(1))
BEGIN
/*declaring local variable*/
declare checkfirstnamecount int;
declare checklastnamecount int;
declare checkpasswordcount int;
delcare checksaltcount int;
declare checkroleidcount int;
declare checkemailcount int;
declare checkexistingemailaddress varchar(30);
/*checking the email address for one count*/
select count(emailaddress) into checkemailcount
from users
where emailaddress = iEmailaddress;
/*checking the password for one count*/
select count(Password) into checkpasswordcount
from users
where Password = iPassword;
/*checking the email address for one count*/
select count(FirstName) into checkfirstnamecount
from users
where FirstName = iFirstName;
/*checking the last name for one count*/
select count(LastName) into checklastnamecount
from users
where LastName = iLastName;
/*checking the salt for one count*/
select count(salt) into checksaltcount
from users
where salt = iSalt;
/*checking the roleid for one count*/
select count(RoleID) into checkroleidcount
from users
where RoleID = iRoleID;
/*checking the email address for one count for if it exists*/
select emailaddress into checkexistingemailaddress
from users
where emailaddress = iEmailaddress;
/*checking for firstname if the user forgot to fill out the first name*/
If(checkfirstnamecount!=1) then
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Fill out the First Name ';
/*checking for Lastname if the user forgot to fill out the last name*/
Elseif(checklastnamecount!=1) then
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Fill out the Last Name';
/ 检查密码是否未填写 / Elseif(checkpasswordcount!= 1)然后
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Fill out the password';
/ 检查盐是否填写 / Elseif(checksaltcount!= 1)然后
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Salt is not found';
/*check if the roleid is not fill out*/
Elseif(checkroleidcount!=1) then
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'RoleID is not found';
Elseif(checkemailcount!=1) then
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Fill out the email address';
/*checking if the emailaddress already exists in the table*/
Elseif(iEmailaddress=checkexistingemailaddress ) then
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Email Address already exists';
Else
insert into users(
FirstName,
LastName ,
Password ,
EmailAddress ,
Salt ,
RoleID
)
Values
(
FirstName,
LastName ,
Password ,
EmailAddress ,
Salt ,
RoleID
);
set UserID = last_insert_id();
end if;
End
go
DELIMITER ;