This discussion is archived
3 Replies Latest reply: Dec 28, 2008 2:17 PM by 439427 RSS

Why Packages?

676895 Newbie
Currently Being Moderated
Anyone can write about the advantages of Packages?

Anyone experienced any problems or disadvantages with packages?

Can we declare a package within a package? (ie. like sub class?)
  • 1. Re: Why Packages?
    675433 Newbie
    Currently Being Moderated
    for advantage/disadvantage, please go to the link [].
    It will give you the detail idea about package.

    Also, we can't create a package inside a package. Package declaration are only allowed at top level. Hence, a package cannot be nested. I got the following error when i tried to create a package inside a package.
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE OR REPLACE PACKAGE test_pkg_1  AS
      2    PROCEDURE test_prc_1;
      3    PACKAGE test_pkg_2 IS
      4       PROCEDURE test_prc_2;
      5    END test_pkg_2;
      6* END test_pkg_1;
    SQL> /
    Warning: Package created with compilation errors.
    SQL> show err
    Errors for PACKAGE TEST_PKG_1:
    -------- -----------------------------------------------------------------
    3/3      PLS-00232: nested packages not permitted
    Edited by: Ritesh S Kumar on Dec 27, 2008 3:18 PM
  • 2. Re: Why Packages?
    Walter Fernández Expert
    Currently Being Moderated

    Packages cannot be nested. The advantage of use package is that it can be used to encapsulate logic, perform complicated task on the database, available code for all users at the same time (compiled on the server).

  • 3. Re: Why Packages?
    439427 Explorer
    Currently Being Moderated
    Advantages of Packages would be

    1) It reduces dependency failures

    2) It allows object oriented design by overloading procedures.

    3) Maintenance wise it is better and the cost is reduced.

    4) If the body changes, no need to re-compile the specifications, just need to compile the body.

    5) Similar objects can be stored logically together using packages.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points