PL allows overloaded programs in a package. Overloaded programs are two or more programs that have the same name but have different parameters and variables, parameter sequences, or data types. You can select a program to call based on the type of input parameters.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
The following example shows a package specification. Methods of the query_obdept function are selected based on whether the input parameter is of a numeric or string type. Then, features are implemented in the package body definition.
CREATE OR REPLACE PACKAGE obdemo_pack1
IS
DeptRec obdept%ROWTYPE;
v_sqlcode NUMBER;
v_sqlerr VARCHAR2(2048);
FUNCTION query_obdept(dept_no IN NUMBER)
RETURN INTEGER;
FUNCTION query_obdept(dept_no IN VARCHAR2)
RETURN INTEGER;
END obdemo_pack1;
/