-
Hi,
Has anybody encountered this ?
I have created a function , which is used in the where clause of the select query. The function is within a package with a WNDS purity level.
There are 3 select statements within the function and it returns a value based on the queries. Since I had to use this function in the where clause , I required a purity level of WNPS as well.
Upon adding this purity level of WNPS, I was having a compilation error that the function is not pure enough to apply WNPS. Upon trying various things, when I commented the exception section of the Function , it compiled correctly and is working.
Can we not have an exception section, if we require a WNPS purity level ?
Thanks
-
This crappy packaged function reads from the database and returns a value. It also contains an exception section and it works fine on 7.3, 8i & 9i. I think your problem must be elsewhere:
CREATE OR REPLACE PACKAGE test IS
FUNCTION Add_Values (v_number1 IN NUMBER,
v_number2 IN NUMBER)
RETURN NUMBER;
PRAGMA RESTRICT_REFERENCES (Add_Values, WNDS, WNPS, RNPS);
END test;
/
CREATE OR REPLACE PACKAGE BODY test IS
FUNCTION Add_Values (v_number1 IN NUMBER,
v_number2 IN NUMBER)
RETURN NUMBER IS
v_date DATE;
BEGIN
SELECT sysdate
INTO v_date
FROM dual;
RETURN v_number1 + v_number2;
EXCEPTION
WHEN OTHERS THEN
RETURN -1;
END;
END test;
/
SELECT Sysdate FROM dual WHERE 3 = test.Add_Values(1,2);
Note:
The whole purity level assignment has been ditched in later versions of 8i so I wouldn't worry about it too much. Oracle decided that the fact Java stored procedures didn't need purity level assignments meant it was stupid to keep them for PL/SQL.