小弟在用plsql写验证登陆信息的存储过程如下。在elsif中验证登陆名的正确性时出现错误。我觉得是应该跳过elsif中进行用户名判断的整个if语句块(红字显示),但实际进行调试时只是跳过了a_error_msg:='错误的用户名';这一句,下面的return语句(蓝字显示)并没跳过。自己有些搞不懂。elsif语句中可以嵌套if..then..end if语句吗?请大家帮帮忙,先谢谢了procedure sp_ver_logininf(a_login_id xg2.users.login_id%type,
a_password xg2.users.password%type,
a_role_id xg2.user_role.role_id%type,
a_error_msg in out nvarchar2) is
v_cnt number;
begin
a_error_msg:='';
if a_login_id is null then
a_error_msg:='缺少用户名';
return;
elsif a_login_id is not null then
select count(*)
into v_cnt
from xg2.users
where lower(login_id)=lower(a_login_id);
if v_cnt<>1 then
a_error_msg:='错误的用户名';
[color=#3366FF]return;
end if;[/color]
elsif a_password is null then
select count(*)
into v_cnt
from xg2.users
where lower(login_id)=lower(a_login_id)
and password is null;
else
select count(*)
into v_cnt
from xg2.users
where lower(login_id)=lower(a_login_id)
and password =a_password;
end if;
if v_cnt <>1 then
a_error_msg:='错误的密码';
return;
end if;
select count(*)
into v_cnt
from xg2.user_role
where lower(login_id)=lower(a_login_id)
and role_id=a_role_id;
if v_cnt<>1 then
a_error_msg:='该用户不具备['||fn_get_rolename(a_role_id)||']的身份';
end if;
end;
a_password xg2.users.password%type,
a_role_id xg2.user_role.role_id%type,
a_error_msg in out nvarchar2) is
v_cnt number;
begin
a_error_msg:='';
if a_login_id is null then
a_error_msg:='缺少用户名';
return;
elsif a_login_id is not null then
select count(*)
into v_cnt
from xg2.users
where lower(login_id)=lower(a_login_id);
if v_cnt<>1 then
a_error_msg:='错误的用户名';
[color=#3366FF]return;
end if;[/color]
elsif a_password is null then
select count(*)
into v_cnt
from xg2.users
where lower(login_id)=lower(a_login_id)
and password is null;
else
select count(*)
into v_cnt
from xg2.users
where lower(login_id)=lower(a_login_id)
and password =a_password;
end if;
if v_cnt <>1 then
a_error_msg:='错误的密码';
return;
end if;
select count(*)
into v_cnt
from xg2.user_role
where lower(login_id)=lower(a_login_id)
and role_id=a_role_id;
if v_cnt<>1 then
a_error_msg:='该用户不具备['||fn_get_rolename(a_role_id)||']的身份';
end if;
end;
a_error_msg:='错误的用户名';
[color=#0000FF]return;
end if; [/color]
a_error_msg:='错误的用户名';
return;
end if;
http://topic.csdn.net/u/20090504/13/7a1c102d-ba05-49db-9298-169081e00485.html
if v_cnt <>1 then
a_error_msg:='错误的用户名';
return;
end if; 这个块
但是在测试的时候发现只是跳过了a_error_msg:='错误的用户名'; 这一句,并没有跳过后面得return语句