以下 sntax 接缝是正确的。在mysql上运行时出现错误
错误代码:1064。您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以获取正确的语法,以便在第 27 行的 '' 附近使用。
delimiter $$
create function check2_login(p_username varchar(30),p_password varchar(30),role varchar(20))
returns bool
deterministic
begin
declare loginstatus bool default false;
if role="customer"then
select custid from customer where custid=p_username and pwd=p_password;
if !row_count()=0 then
select true into loginstatus;
end if;
else if role="executive"then
select execid from executive where execid=p_username and pwd=p_password;
if !row_count()=0 then
select true into loginstatus;
end if;
else if role="admin"then
select empid from employee where empid=p_username and pwd=p_password;
if !row_count()=0 then
select true into loginstatus;
end if;
else
return loginstatus;
end if;
return loginstatus;
end $$