An Oracle database cannot determine the work done by a packaged function when the function is executed from inside a DML statement. Therefore, if packaged functions are to be executed from within a DML statement, developers must use a PRAGMA to define a purity level for functions defined as part of the package spec. A PRAGMA is a compiler directive that instructs the compiler to handle code in a specific manner. To define a purity level for a packaged function, the PRAGMA RESTRICT_REFERENCES is used.
WNDS | Write No Database State. The function doesn’t alter the contents of any database table. |
RNDS | Read No Database State. The function doesn’t read the contents of any database table. |
WNPS | Write No Package State. The function doesn’t alter any variables within another package. |
RNPS | Read No Package State. The function doesn’t read any variables within another package. |
CREATE OR REPLACE PACKAGE P_TEST
FUNCTION GET_ID RETURN NUMBER;
PRAGME RESTRICT_REFERENCES(GET_ID,WNDS);
END;
No comments:
Post a Comment