Creating an Oracle package is one of the most common operations when we use an Oracle database. The following describes the syntax for creating an Oracle package. Package is one
Creating an Oracle package is one of the most common operations when we use an Oracle database. The following describes the syntax for creating an Oracle package. Package is one
Creating an Oracle package is one of the most common operations when we use an Oracle database. The following describes the syntax for creating an Oracle package.
A package is a container that binds processes, functions, and data structures. A package consists of two parts: external visual package specifications, including function headers, and process headers, the package body contains the declaration, execution, and exception handling of all bundled processes and functions.
The packaged PL/SQL program is very different from the one not packaged. The package data exists throughout the user's session. When the user obtains the package execution authorization, it is equivalent to obtaining permissions for all programs and data structures in the package specification. However, you cannot only authorize a function or process in the package. The package can reload processes and functions. In the package, multiple programs can be declared with the same name. during runtime, the correct program is called based on the number of parameters and data types.
To create an Oracle package, you must first create a package specification. The syntax for creating an Oracle package specification is as follows:
CREATE [or replace] PACKAGE package_name
{AS | IS}
Public_variable_declarations |
Public_type_declarations |
Public_exception_declarations |
Public_cursor_declarations |
Function_declarations |
Procedure_specifications
END [package_name]
Use the create package body statement to CREATE a package body:
CREATE [or replace] package body package_name
{AS | IS}
Private_variable_declarations |
Private_type_declarations |
Private_exception_declarations |
Private_cursor_declarations |
Function_declarations |
Procedure_specifications
END [package_name]
Private Data structures are those inside the package body and are invisible to the called program.