我目前正在研究Oracle Application Express 5中的應用程序,更具體地說,我正嘗試創建自定義身份驗證方案。身份驗證 - PLS-00488:'VALIDATE_USER_FROM_DB'必須是一個類型ORA-06550
我通過在SQL命令窗口中創建一個函數來開始,它將爲我的應用程序提供一個基本的身份驗證級別。我希望我的用戶能夠使用他的個人學生參考號(srn)和出生日期(dob)登錄,並且此信息來自「學生」表。
create or replace function validate_user_from_db
(p_username in number, p_password in date)
return boolean
as v_pw_check varchar2(1);
begin select 'x' into v_pw_check
from student
where upper(srn) = upper(p_username)
and dob = p_password; apex_util.set_authentication_result(0);
return true; exception when no_data_found then apex_util.set_authentication_result(4);
return false;
end validate_user_from_db;
這個函數編譯沒有錯誤,所以我接着創建了一個簡單的查詢來測試函數。
declare
vresult varchar2(10);
begin
if validate_user_from_db ('30134852', '08/17/1997') then
DBMS_OUTPUT.PUT_LINE('Welcome Back');
else
DBMS_OUTPUT.PUT_LINE('Error');
end if;
end;
查詢成功,並且在填寫正確憑證時輸出「Welcome Back」。現在一切正常,我希望如何創建一個新的身份驗證方案。我將其命名爲「用戶驗證」並將方案類型設置爲自定義。
我一直在下面的教程和研究爲身份驗證方案,並建議,在PL/SQL代碼,我把行,
return validate_user_from_db;
但是當我保存並編譯它,我得到這個錯誤信息。
在試圖嘗試解決這個問題,我決定寫在PL/SQL代碼窗口中下面的函數,它沒有任何問題的編譯,但是當我嘗試運行應用程序,並使用正確的登錄憑據它只是給我一個錯誤消息,指出「無效的登錄證書」。
function validate_user_from_db
(p_username in number, p_password in date)
return boolean
as v_pw_check varchar2(1);
begin select 'x' into v_pw_check
from student
where upper(srn) = upper(p_username)
and dob = p_password; apex_util.set_authentication_result(0);
return true; exception when no_data_found then apex_util.set_authentication_result(4);
return false;
end validate_user_from_db;
任何幫助將非常感謝,因爲這是我第一次使用Oracle Apex創建身份驗證。
'return validate_user_from_db;' - 你錯過了函數的參數。另外,你不應該依賴隱含的字符串 - >日期轉換:提供'08/17/1997'作爲日期輸入值將失敗,除非你使用美國NLS設置。以明確的日期格式使用to_char(),或使用接受ISO格式日期的'date'運算符,例如'日期'2016-08-17'' –