我正在尝试使用一个过程验证创建一个名为 MSGG_SESSION 的包,该过程接受两个 VARCHAR2 参数作为用户名和密码。我想为当前人员 ID 放置一个包私有 NUMBER 变量。如果“authenticate”与 MSGG_USER 中的用户名和密码匹配,则将匹配的 PERSON_ID 放入新变量中。将函数 get_user_id 添加到返回包含人员 ID 的变量的值的包中。
但我得到两个错误,说表或视图从第二个开始没有退出是在 not_authenticated_exception 之前
从 priv_number varchar2(100) 开始忽略 sql 语句。
CREATE OR REPLACE PACKAGE MSGG_SESSION IS
PROCEDURE AUTHENTICATE (USERNAME_to_auth IN VARCHAR2, PASSWORD_to_use IN VARCHAR2);
FUNCTION AUTHENTICATED_USER RETURN VARCHAR2;
END MSGG_SESSION;
/
create or replace package body msgg_session is
priv_number varchar2(100);
procedure authenticate (username_to_auth in varchar2, password_to_use in varchar2)
is
not_authenticated exception;
begin
select username
into priv_number
from user_password
where lower(username) = lower(username_to_auth)
and password = password_to_use;
exception
when no_data_found then
begin
raise not_authenticated;
exception
when not_authenticated then
raise_application_error(-20000, 'Not authenticated');
end;
when others then
raise;
end authenticate;
function authenticated_user
return varchar2
is
begin
return null;
end;
function get_user_id
return varchar2
is
begin
return priv_number;
end get_user_id;
end msgg_session;
/