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:

15-13.

This code allows you to deduce (and create) the package specification:


/* Filename on web page: timer.pkg */
CREATE OR REPLACE PACKAGE timer
IS
   PROCEDURE capture;
   PROCEDURE show_elapsed;
END timer;
/

To create the body, you need to not only define the two procedures but also create a global data structure to hold the “time before” you’ll use to subtract from the “time after.” Here is the complete package:


/* Filename on web page: timer.pkg */
CREATE OR REPLACE PACKAGE BODY timer
IS
   last_timing INTEGER := NULL;

   PROCEDURE capture IS
   BEGIN
     last_timing := DBMS_UTILITY.GET_TIME;
   END;

   PROCEDURE show_elapsed IS
   BEGIN
      DBMS_OUTPUT.PUT_LINE (
        'Elapsed time: ' ||
        (DBMS_UTILITY.GET_TIME - last_timing)/100);
   END;

END timer;
/

Q:

15-14.

You cannot declare a cursor variable as part of a package; you can only declare a cursor variable within PL/SQL blocks.

Q:

15-15.

For each of the examples, the block:

  1. Does not compile. Within Oracle Developer (at least through version 2.1), you can reference only stored packaged elements if the elements are functions or procedures. You can’t reference constants, variables, TYPEs, or exceptions.

  2. Compiles. This block is fine.

  3. Does not compile. See explanation for (a).

Q:

15-16.

Here is one possible way to add trace and validation capabilities to the sessval ...

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