Skip to 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
594 pages
11h 32m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL Programming: A Developer's Workbook

Chapter 15. Packages

A package is a named collection of procedures, functions, and data structures. A package has two parts: a specification, which lists its publicly available elements, and a body, which contains the actual implementations for the procedures and functions listed in the specification (the body can also contain private procedures, functions, and data structures that are available only within the package itself). This chapter tests your ability to define your own packages, create packaged data structures such as cursors, and use packages to encapsulate, or hide, the implementation details (e.g., data structures) of your programs.

Beginner

15-1.

Is it possible to execute a package?

15-2.

If I want to call a procedure named “calc_totals” in the “financial_pkg” package, how would I write the code?

15-3.

What are the exceptions to the dot-notation rule for packaged elements? In other words, when don’t you need to qualify a package element with its package name?

15-4.

List all the packages referenced in the following piece of code, and say what types of packaged elements are used:

DECLARE
   v_new_pet pet.pet_id%TYPE;
   v_last_appointment DATE;
BEGIN
   IF pets_r_us.max_pets_in_facility >
         TO_NUMBER (v_current_count)
   THEN
      /* Add another pet ... */
   ELSE
      DBMS_OUTPUT.PUT_LINE ('Facility is full');
   END IF;
EXCEPTION
   WHEN pets_r_us.pet_is_sick
   THEN
      ...
   WHEN NO_DATA_FOUND
   THEN
      RAISE_APPLICATION_ERROR (
         -20555, 'Pet not found');
END;

15-5.

Write a package specification that contains a DATE variable ...

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 11g PL/SQL Programming Workbook

Oracle Database 11g PL/SQL Programming Workbook

Michael McLaughlin, John Harper

Publisher Resources

ISBN: 9781449324070Supplemental ContentErrata Page