Oracle PRAGMA DEPRECATE
Version 19.3

General Information
Library Note Morgan's Library Page Header
For how many years have you been working with physical servers that are starving your database of the memory necessary to deploy important new performance features such as the Result Cache, Memoptimize Pool, In-Memory Aggregation, In-Memory Column Store, and Full Database Caching? Too long? Contact me to learn how to improve all queries ... not just some queries.
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
Deprecate a PL/SQL package

Note the messages in red, at right, is a warning not an exception.
PRAGMA DEPRECATE (<pls_identifier> [, <character_literal>);
ALTER SESSION SET PLSQL_WARNINGS='ENABLE:(6019,6020,6021,6022)';

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/2 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.

Note the messages in red, at right, is a warning not an exception.
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/2 PLW-06019: entity PRAGMA_DEP is deprecated
Deprecate of a single PL/SQL procedure in a package

Note the messages in red, at right, is a warning not an exception.
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
Deprecate a specific overload of a procedure name. Only the second declaration is deprecated in 12.1.0.2 but in 18 an exception is raised. CREATE OR REPLACE 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
No errors.
SQL>
Deprecate a variable and an exception

Note the messages in red, at right, is a warning not 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

Note the messages in red, at right, is a warning not an exception.
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 18cR3
What's New In 19cR3

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-2019 Daniel A. Morgan All Rights Reserved