Oracle-style packages were introduced in MariaDB 10.3.5.
CREATE [ OR REPLACE] [DEFINER = { user | CURRENT_USER | role | CURRENT_ROLE }] PACKAGE [ IF NOT EXISTS ] [ db_name . ] package_name [ package_characteristic ... ] { AS | IS } [ package_specification_element ... ] END [ package_name ] package_characteristic: COMMENT 'string' | SQL SECURITY { DEFINER | INVOKER } package_specification_element: FUNCTION_SYM package_specification_function ; | PROCEDURE_SYM package_specification_procedure ; package_specification_function: func_name [ ( func_param [, func_param]... ) ] RETURNS func_return_type [ package_routine_characteristic... ] package_specification_procedure: proc_name [ ( proc_param [, proc_param]... ) ] [ package_routine_characteristic... ] func_return_type: type func_param: param_name type proc_param: param_name { IN | OUT | INOUT | IN OUT } type type: Any valid MariaDB explicit or anchored data type package_routine_characteristic: COMMENT 'string' | LANGUAGE SQL | { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA } | SQL SECURITY { DEFINER | INVOKER }
The CREATE PACKAGE
statement can be used when Oracle SQL_MODE is set.
The CREATE PACKAGE
creates the specification for a stored package (a collection of logically related stored objects). A stored package specification declares public routines (procedures and functions) of the package, but does not implement these routines.
A package whose specification was created by the CREATE PACKAGE
statement, should later be implemented using the CREATE PACKAGE BODY statement.
SET sql_mode=ORACLE; DELIMITER $$ CREATE OR REPLACE PACKAGE employee_tools AS FUNCTION getSalary(eid INT) RETURN DECIMAL(10,2); PROCEDURE raiseSalary(eid INT, amount DECIMAL(10,2)); PROCEDURE raiseSalaryStd(eid INT); PROCEDURE hire(ename TEXT, esalary DECIMAL(10,2)); END; $$ DELIMITER ;
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/create-package/