Package method overloading : Package Body « Function Procedure Packages « Oracle PL/SQL Tutorial






SQL>
SQL> CREATE OR REPLACE PACKAGE outputPackage
  2  IS
  3     PROCEDURE printLine (val IN VARCHAR2);
  4
  5     PROCEDURE printLine (val IN DATE);
  6
  7     PROCEDURE printLine (val IN NUMBER);
  8
  9     PROCEDURE printLine (val IN BOOLEAN);
 10  END outputPackage;
 11  /

Package created.

SQL>
SQL> CREATE OR REPLACE PACKAGE BODY outputPackage
  2  IS
  3     PROCEDURE printLine (val IN DATE) IS
  4     BEGIN
  5        printLine (TO_CHAR (val, 'MM/DD/YYYY HH24:MI:SS'));
  6     END;
  7
  8     PROCEDURE printLine (val IN NUMBER) IS
  9     BEGIN
 10        printLine (TO_CHAR (val));
 11     END;
 12
 13     PROCEDURE printLine (val IN BOOLEAN) IS
 14     BEGIN
 15        IF val
 16        THEN
 17           printLine ('TRUE');
 18        ELSIF NOT val
 19        THEN
 20           printLine ('FALSE');
 21        ELSE
 22           printLine ('');
 23        END IF;
 24     END;
 25
 26     PROCEDURE printLine (val IN VARCHAR2)
 27     IS
 28     BEGIN
 29        IF LENGTH (val) > 80
 30        THEN
 31           DBMS_OUTPUT.put_line (SUBSTR (val, 1, 80));
 32           printLine (SUBSTR (val, 81));
 33        ELSE
 34           DBMS_OUTPUT.put_line (val);
 35        END IF;
 36     EXCEPTION
 37        WHEN OTHERS
 38        THEN
 39           DBMS_OUTPUT.enable (1000000);
 40           printLine (val);
 41     END;
 42  END outputPackage;
 43  /

Package body created.








27.11.Package Body
27.11.1.Package with only one function
27.11.2.Package with two procedures
27.11.3.Package declaration and body
27.11.4.Use of 'get' and 'set' prefixes
27.11.5.Use package method in a procedure
27.11.6.Call function in a Package
27.11.7.Method overload
27.11.8.Package method overloading
27.11.9.Reference method from another package
27.11.10.Package Function with 'PRAGMA AUTONOMOUS_TRANSACTION'
27.11.11.Create a package containing stored procedure DELETE_ORDERS and stored function GET_employee_NAME.
27.11.12.Package initialization.
27.11.13.Use package member variable to pass value