这是我的职责
---Write procedure for retrive data----
CREATE OR REPLACE FUNCTION retrieve_decrypt(
custid in NUMBER
)
RETURN sys_refcursor
IS
decrypt_value sys_refcursor;
BEGIN
open decrypt_value for Select custname,contactno, enc_dec.decrypt(creditcardno,password) as
creditcardno ,enc_dec.decrypt(income,password) as
income from employees where custid=custid ;
RETURN decrypt_value;
END;
/
我这样称呼它:SELECT retrieve_decrypt(5) FROM DUAL;
然后它只返回{}。
但是我是由custid=5
插入的硬编码custid=custid
。它将正确返回结果。需要一些专家帮助来解决此问题。
答案 0 :(得分:1)
不要将参数命名为列;如果列名是custid
,则将参数设为par_custid
。否则,将导致问题(如您所见)。
在您的示例中:
CREATE OR REPLACE FUNCTION retrieve_decrypt (par_custid IN NUMBER)
RETURN SYS_REFCURSOR
IS
decrypt_value SYS_REFCURSOR;
BEGIN
OPEN decrypt_value FOR
SELECT custname,
contactno,
enc_dec.decrypt (creditcardno, password) AS creditcardno,
enc_dec.decrypt (income, password) AS income
FROM employees
WHERE custid = par_custid;
RETURN decrypt_value;
END;
/