Use RESTRICT_REFERENCES with overloaded subprograms.
SQL>
SQL> CREATE OR REPLACE PACKAGE Overload AS
2 FUNCTION TestFunc(p_Parameter1 IN NUMBER)
3 RETURN VARCHAR2;
4 PRAGMA RESTRICT_REFERENCES(TestFunc, WNDS, RNDS, WNPS, RNPS);
5
6 FUNCTION TestFunc(p_ParameterA IN VARCHAR2,
7 p_ParameterB IN DATE)
8 RETURN VARCHAR2;
9 PRAGMA RESTRICT_REFERENCES(TestFunc, WNDS, RNDS, WNPS, RNPS);
10 END Overload;
11 /
Package created.
SQL>
SQL> CREATE OR REPLACE PACKAGE BODY Overload AS
2 FUNCTION TestFunc(p_Parameter1 IN NUMBER)
3 RETURN VARCHAR2 IS
4 BEGIN
5 RETURN 'Version 1';
6 END TestFunc;
7
8 FUNCTION TestFunc(p_ParameterA IN VARCHAR2,
9 p_ParameterB IN DATE)
10 RETURN VARCHAR2 IS
11 BEGIN
12 RETURN 'Version 2';
13 END TestFunc;
14 END Overload;
15 /
Package body created.
SQL>
SQL> SELECT Overload.TestFunc(1) FROM dual;
OVERLOAD.TESTFUNC(1)
--------------------------------------------------------------------------------
Version 1
SQL> SELECT Overload.TestFunc('abc', SYSDATE) FROM dual;
OVERLOAD.TESTFUNC('ABC',SYSDATE)
--------------------------------------------------------------------------------
Version 2
SQL>
Related examples in the same category