I searched google but did not find any satisfying answer as to why I should use packages.
I know that a package is a bundle of procedures, functions and different variables. As I understand it sort of corresponds to object in OOP. But of course there's nothing like instantiating different instances of a package so that each instance would have different property values and behave differently.
Then what is the advantage of using packages when I can just create a standalone procedure and call it independently?
Benefits of Packages Packages are used to define related procedures, variables, and cursors and are often implemented to provide advantages in the following areas: encapsulation of related procedures and variables. declaration of public and private procedures, variables, constants, and cursors. better performance.
Packages prevent cascading dependencies and unnecessary recompiling. For example, if you change the body of a package function, Oracle Database does not recompile other subprograms that invoke the function, because these subprograms depend only on the parameters and return value that are declared in the specification.
The advantage of a package over a stand-alone procedure is that all the procedures and functions are loaded into memory so that when one procedure within the package calls another within the same package it is already loaded so this should give performance benefits if designed properly.
Packages provide the following advantages:
As described in Oracle docs, packages are good because of:
Details on each reason are explained in docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With