RESTRICT_REFERENCES Pragma
Prior to Oracle8i, it was necessary to assert the purity level of a packaged procedure or function when using it directly or indirectly in a SQL statement. Beginning with Oracle8i, the PL/SQL runtime engine determines a program’s purity level automatically if no assertion exists. The RESTRICT REFERENCES pragma is still supported for backwards compatibility but it has been deprecated in Oracle9i.
The RESTRICT_REFERENCES pragma asserts a purity level. The syntax for the RESTRICT_REFERENCES pragma is:
PRAGMA RESTRICT_REFERENCES (program_name
| DEFAULT,purity_level
);
The keyword DEFAULT applies to all methods of an object type or all programs in a package.
You can specify from one to five purity levels, in any order, in a comma-delimited list. The purity level describes to what extent the program or method is free of side effects. Side effects are listed in the Table 9-3 with the purity levels they address.
Table 9-3. Purity levels and side effects
Purity level |
Description |
Restriction |
---|---|---|
WNDS |
Write No Database State |
Executes no INSERT, UPDATE, or DELETE statements |
RNDS |
Read No Database State |
Executes no SELECT statements |
WNPS |
Write No Package State |
Does not modify any package variables |
RNPS |
Read No Package State |
Does not read any package variables |
TRUST |
Does not enforce the restrictions declared but allows the compiler to trust they are true |
Get Oracle in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.