CREATE PACKAGE BODY
Implement the logic for a stored package. This statement defines the private variables and code for the subroutines declared in the package specification.
The CREATE PACKAGE BODY statement can be used in any mode.
The CREATE PACKAGE BODY statement can be used in Oracle SQL_MODE.
In Oracle mode, the PL/SQL dialect is used, while in non-Oracle mode, SQL/PSM is used.
Syntax (Oracle mode)
CREATE [ OR REPLACE ]
[DEFINER = { user | CURRENT_USER | role | CURRENT_ROLE }]
PACKAGE BODY
[ IF NOT EXISTS ]
[ db_name . ] package_name
[ package_characteristic... ]
{ AS | IS }
package_implementation_declare_section
package_implementation_executable_section
END [ package_name]
package_implementation_declare_section:
package_implementation_item_declaration
[ package_implementation_item_declaration... ]
[ package_implementation_routine_definition... ]
| package_implementation_routine_definition
[ package_implementation_routine_definition...]
package_implementation_item_declaration:
variable_declaration ;
variable_declaration:
variable_name[,...] type [:= expr ]
package_implementation_routine_definition:
FUNCTION package_specification_function
[ package_implementation_function_body ] ;
| PROCEDURE package_specification_procedure
[ package_implementation_procedure_body ] ;
package_implementation_function_body:
{ AS | IS } package_routine_body [func_name]
package_implementation_procedure_body:
{ AS | IS } package_routine_body [proc_name]
package_routine_body:
[ package_routine_declarations ]
BEGIN
statements [ EXCEPTION exception_handlers ]
END
package_routine_declarations:
package_routine_declaration ';' [package_routine_declaration ';']...
package_routine_declaration:
variable_declaration
| condition_name CONDITION FOR condition_value
| user_exception_name EXCEPTION
| CURSOR_SYM cursor_name
[ ( cursor_formal_parameters ) ]
IS select_statement
;
package_implementation_executable_section:
END
| BEGIN
statement ; [statement ; ]...
[EXCEPTION exception_handlers]
END
exception_handlers:
exception_handler [exception_handler...]
exception_handler:
WHEN_SYM condition_value [, condition_value]...
THEN_SYM statement ; [statement ;]...
condition_value:
condition_name
| user_exception_name
| SQLWARNING
| SQLEXCEPTION
| NOT FOUND
| OTHERS_SYM
| SQLSTATE [VALUE] sqlstate_value
| mariadb_error_codeDescription
The CREATE PACKAGE BODY statement creates the package body for a stored package. The package specification must be previously created using the CREATE PACKAGE statement.
A package body provides implementations of the package public routines and can optionally have:
package-wide private variables
package private routines
forward declarations for private routines
an executable initialization section
Examples
See Also
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?

