Turn on Compile-Time Warnings
ALTER SESSION SET plsql_warnings = 'enable:all'
Statement processed.
Mark Entire Package as Deprecated
CREATE OR REPLACE PACKAGE pkg
AUTHID DEFINER
AS
PRAGMA DEPRECATE(pkg);
PROCEDURE proc;
FUNCTION func RETURN NUMBER;
END;
Warning: PACKAGE PKG Line: 4 PLW-06019: entity PKG is deprecatedMore Details: https://docs.oracle.com/error-help/db/ora-20001
Add Package Body
CREATE OR REPLACE PACKAGE BODY pkg
AS
PROCEDURE proc
IS
BEGIN
DBMS_OUTPUT.put_line ('old stuff');
END;
FUNCTION func
RETURN NUMBER
IS
BEGIN
RETURN 1;
END;
END;
Package Body created.
Try Using Deprecated Unit
CREATE OR REPLACE PROCEDURE use_deprecated AUTHID DEFINER
IS
BEGIN
pkg.proc;
END;
Warning: PROCEDURE USE_DEPRECATED Line: 4 PLW-06020: reference to a deprecated entity: PKG declared in unit PKG[1,9]More Details: https://docs.oracle.com/error-help/db/ora-20001
Change Warnings into Errors
ALTER SESSION SET plsql_warnings='ERROR:(6019,6020,6021,6022)'
Statement processed.
Oh Wait Maybe Not 6019
CREATE OR REPLACE PACKAGE pkg
AUTHID DEFINER
AS
PRAGMA DEPRECATE(pkg);
PROCEDURE proc;
FUNCTION func RETURN NUMBER;
END;
Errors: PACKAGE PKG Line: 4 PLS-06019: entity PKG is deprecatedMore Details: https://docs.oracle.com/error-help/db/ora-24344
Deprecated Usages Set to Errors
ALTER SESSION SET plsql_warnings='ERROR:(6020,6021,6022)'
Statement processed.
Deprecated Package Still Compiles Without Error
CREATE OR REPLACE PACKAGE pkg
AUTHID DEFINER
AS
PRAGMA DEPRECATE(pkg);
PROCEDURE proc;
FUNCTION func RETURN NUMBER;
END;
Package created.
Deprecate Subprogram in Package
CREATE OR REPLACE PACKAGE pkg
AUTHID DEFINER
AS
PROCEDURE proc;
PRAGMA DEPRECATE (proc, 'pkg.proc deprecated. Use pkg.new_proc instead.');
PROCEDURE new_proc;
END;
Package created.
Create Package Body
CREATE OR REPLACE PACKAGE BODY pkg
AS
PROCEDURE proc
IS
BEGIN
DBMS_OUTPUT.put_line ('old stuff');
END;
PROCEDURE new_proc
IS
BEGIN
DBMS_OUTPUT.put_line ('new stuff');
END;
END;
Package Body created.
Try to Use Deprecated Procedure
CREATE OR REPLACE PROCEDURE use_deprecated
IS
BEGIN
pkg.proc;
END;
Errors: PROCEDURE USE_DEPRECATED Line: 4 PLS-06020: reference to a deprecated entity: PROC declared in unit PKG[4,14]. pkg.proc deprecated. Use pkg.new_proc instead.More Details: https://docs.oracle.com/error-help/db/ora-24344