Looking for a canonical answer to the question of why packages should be preferred in an Oracle database over stand alone procedures and functions.
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
Benefits of Packages
Logical Grouping – Methods that work together can be put into a cohesive unit rather than just logically coupled but physically separate.
Secure Private Methods - Functions and Procedures can be made private to the package and only be used within it. This makes the public surface simpler and more secure.
Privilege Management – Permissions can be granted once for a group of procedures that work together rather than separately for each procedure/function required.
Secure Wrapping - Wrapped packages are more difficult to unwrap than wrapped functions/procedures.
Simplified Naming – A larger namespace allows names that are simpler and can be re-used in other packages.
Better Performance – Packages can be compiled and are loaded into memory in entirety rather than piecemeal as other methods. This benefit if it exists at all is minimal compared to the other benefits.
Reduced Invalidation – Changing a package body does not invalidate dependencies as changing a function or procedure does.
Unique Features - Package Variables, Package Constants, Initialization, Session State, Package Comments, and Overloaded Methods.