Oracle - Why should I use packages instead of standalone procedures or functions

As described in Oracle docs, packages are good because of:

  • modularity
  • easier application design
  • information hiding
  • added functionality
  • better performance

Details on each reason are explained in docs.


Packages provide the following advantages:

  1. Cohesion: all the procedures and functions relating to a specfic sub-system are in one program unit. This is just good design practice but it's also easier to manage, e.g. in source control.
  2. Constants, sub-types and other useful things: there's more to PL/SQL than stored procedures. Anything we can define in a package spec can be shared with other programs, for instance user-defined exceptions.
  3. Overloading: the ability to define a procedure or function with the same name but different signatures.
  4. Security: defining private procedures in the package body which can only be used by the package because they aren't exposed in the specification.
  5. Sharing common code: another benefit of private procedures.
  6. We only need to grant EXECUTE on a package rather than on several procedures.