Oracle PRAGMA DEPRECATE
Version 12.2.0.1

General Information
Library Note Morgan's Library Page Header
"To announce that there must be no criticism of the president or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public."
~ US President Theodore Roosevelt (R)
Purpose The DEPRECATE pragma marks a PL/SQL element as deprecated. The compiler issues warnings for uses of pragma DEPRECATE or of deprecated elements. The associated warnings tell users of a deprecated element that other code may need to be changed to account for the deprecation.
Documented No
First Available 12.2.0.1
 
COVERAGE (new 12.2)
Deprecate a PL/SQL package PRAGMA DEPRECATE (<pls_identifier> [, <character_literal>);
ALTER SESSION SET PLSQL_WARNINGS='ENABLE:(6019,6020,6021,6022)';

SQL> CREATE OR REPLACE PACKAGE pragma_dep AUTHID DEFINER IS
PRAGMA DEPRECATE(pragma_dep);
PROCEDURE foo;
PROCEDURE bar;
END pragma_dep;
/
SP2-0808: Package created with compilation warnings

SQL> sho err
Errors for PACKAGE PRAGMA_DEP:

LINE/COL ERROR
-------- -----------------------------------------------------------------
2/3 PLW-06019: entity PRAGMA_DEP is deprecated
Deprecation a PL/SQL package with a custom warning message when a reference in another unit for the deprecated procedure is compiled CREATE OR REPLACE PACKAGE pragma_dep AUTHID DEFINER IS
 PRAGMA DEPRECATE(pragma_dep , 'Package PRAGMA_DEP has been deprecated, use PRAGMA_NONDEP.');
  PROCEDURE foo;
  PROCEDURE bar;
END pragma_dep;
/
SP2-0808: Package created with compilation warnings

SQL> sho err
Errors for PACKAGE PRAGMA_DEP:

LINE/COL ERROR
-------- -----------------------------------------------------------------
2/1 PLW-06019: entity PRAGMA_DEP is deprecated
Deprecate of a single PL/SQL procedure in a package SQL> CREATE OR REPLACE PACKAGE pragma_dep AUTHID CURRENT_USER IS
  PROCEDURE foo;
 PRAGMA DEPRECATE(foo, 'pragma_dep.foo is deprecated, use pragma_dep.bar instead.');
  PROCEDURE bar;
END pragma_dep;
/
SP2-0808: Package created with compilation warnings

SQL> sho err
Errors for PACKAGE PRAGMA_DEP:

LINE/COL ERROR
-------- -----------------------------------------------------------------
3/3 PLW-06019: entity FOO is deprecated
Depreate a specific overload of a procedure name. Only the second declaration is deprecated CREATE OR REPLACE PACKAGE PACKAGE pragma_dep AUTHID DEFINER IS
  PROCEDURE proc1(n1 IN NUMBER, n2 IN NUMBER);
  PROCEDURE proc1(d1 IN DATE, d2 IN DATE);
  PRAGMA DEPRECATE(proc1);
END pragma_dep;
/
Warning: Package created with compilation errors.

SQL> sho err
Errors for PACKAGE PRAGMA_DEP:

LINE/COL ERROR
-------- -----------------------------------------------------------------
3/3 PLW-06019: entity FOO is deprecated
Deprecate a variable and an exception CREATE OR REPLACE PACKAGE trans_data AUTHID DEFINER IS
 TYPE Transrec IS RECORD(accounttype VARCHAR2(30), ownername VARCHAR2(30), balance REAL);
 min_balance CONSTANT NUMBER(10,2) := 10.0;
 PRAGMA DEPRECATE(min_balance, 'Minimum balance requirement has been removed.');
 PRAGMA DEPRECATE(insufficient_funds, 'Exception no longer raised.');
 insufficient_funds EXCEPTION;
END trans_data;
/
SP2-0808: Package created with compilation warnings

SQL> sho err
Errors for PACKAGE TRANS_DATA:

LINE/COL ERROR
-------- -----------------------------------------------------------------
4/2 PLW-06019: entity MIN_BALANCE is deprecated
5/9 PLW-06021: PRAGMA DEPRECATE on INSUFFICIENT_FUNDS is misplaced
Deprecation a procedure if the database version is greater than 11

The demo, at right, was tested in 12.2.0.1.
CREATE OR REPLACE PACKAGE pragma_dep AUTHID DEFINER IS
  $IF DBMS_DB_VERSION.VER_LE_11 $THEN
    PROCEDURE proc1;
  $ELSE
    PROCEDURE proc1;
    PRAGMA DEPRECATE(proc1);
  $END
  PROCEDURE proc2;
  PROCEDURE proc3;
END pragma_dep;
/
SP2-0808: Package created with compilation warnings

SQL> sho err
Errors for PACKAGE PRAGMA_DEP:

LINE/COL ERROR
-------- -----------------------------------------------------------------
6/5 PLW-06019: entity PROC1 is deprecated

Related Topics
AUTONOMOUS_TRANSACTION
Built-in Functions
Built-in Packages
DEPRECATION
EXCEPTION_INIT
FIPSFLAG
INLINE
Pragmas
SERIALLY_REUSABLE
SUPPLEMENTAL_LOG_DATA
What's New In 12cR1
What's New In 12cR2

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2017 Daniel A. Morgan All Rights Reserved