Skip to Main Content
Oracle PL/SQL Programming: A Developer's Workbook
book

Oracle PL/SQL Programming: A Developer's Workbook

by Steven Feuerstein, Andrew Odewahn
May 2000
Intermediate to advanced content levelIntermediate to advanced
594 pages
11h 32m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL Programming: A Developer's Workbook

Intermediate

Q:

17-6.

Prior to Oracle8i Release 8.1, it was necessary to add the RESTRICT_REFERENCES pragma for each function or procedure you wanted to enable for direct or indirect access from SQL. This pragma informs the compiler of how free or pure the program is from “side effects,” such as modifying data in the database.

Q:

17-7.

You can try to assert any combination of the following:

WNDS

Writes no database state; no modifications made to database tables.

WNPS

Writes no package state; no modifications made to package variables.

RNDS

Reads no database state; no queries against database tables or other database objects.

RNPS

Reads no package state; no read accesses of package variables.

Your program will not compile if you try to assert a purity level that is not supported by the code itself.

Q:

17-8.

You must supply the name of the program and then each of the purity levels:

CREATE OR REPLACE PACKAGE comp
IS
   FUNCTION total
      (sal_in IN NUMBER,
       comm_in IN NUMBER := NULL)
      RETURN NUMBER;

   PRAGMA RESTRICT_REFERENCES (
      total, WNDS, WNPS, RNDS, RNPS);
END;
/

Q:

17-9.

No program can be called directly or indirectly from SQL if it updates the database. At a minimum, you must include the following pragma to make the function usable:

PRAGMA RESTRICT_REFERENCES (my_function, WNDS);

Q:

17-10.

In Oracle 8.0 and earlier, you need to assert the WNPS purity level (in addition to the WNDS level) if you want to call a function:

  • In the WHERE, GROUP BY, or ORDER BY clauses of a SELECT statement

  • As a remote procedure call ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle Database 12c PL/SQL Programming

Oracle Database 12c PL/SQL Programming

Michael McLaughlin
Oracle PL/SQL for DBAs

Oracle PL/SQL for DBAs

Arup Nanda, Steven Feuerstein
Oracle PL/SQL For Dummies

Oracle PL/SQL For Dummies

Michael Rosenblum, Paul Dorsey

Publisher Resources

ISBN: 9781449324070Supplemental ContentErrata Page