Overloaded packages.
SQL>
SQL> CREATE OR REPLACE PACKAGE Overload AS
2 FUNCTION TestFunc(p1 IN NUMBER)
3 RETURN VARCHAR2;
4 PRAGMA RESTRICT_REFERENCES(TestFunc, WNDS, RNDS, WNPS, RNPS);
5
6 FUNCTION TestFunc(pA IN VARCHAR2,pB IN DATE)
7 RETURN VARCHAR2;
8 PRAGMA RESTRICT_REFERENCES(TestFunc, WNDS, RNDS, WNPS, RNPS);
9 END Overload;
10 /
Package created.
SQL> show errors
No errors.
SQL>
SQL> CREATE OR REPLACE PACKAGE BODY Overload AS
2 FUNCTION TestFunc(p1 IN NUMBER)
3 RETURN VARCHAR2 IS
4 BEGIN
5 RETURN 'Version 1';
6 END TestFunc;
7
8 FUNCTION TestFunc(pA IN VARCHAR2,pB IN DATE)
9 RETURN VARCHAR2 IS
10 BEGIN
11 RETURN 'Version 2';
12 END TestFunc;
13 END Overload;
14 /
Package body created.
SQL> show errors
No errors.
SQL>
SQL> SELECT Overload.TestFunc(1) FROM dual;
OVERLOAD.TESTFUNC(1)
--------------------------------------------------------------------------------
Version 1
1 row selected.
SQL> SELECT Overload.TestFunc('abc', SYSDATE) FROM dual;
OVERLOAD.TESTFUNC('ABC',SYSDAT
--------------------------------------------------------------------------------
Version 2
1 row selected.
SQL>
Related examples in the same category