Oracle PRAGMA DEPRECATE
Version 21c

General Information
Library Note Morgan's Library Page Header
Which has the higher priority in your organization: Deploying a new database or securing the ones you already have? Looking for a website, and resources, dedicated solely to securing Oracle databases? Check out DBSecWorx.
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
 
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
Deprecate 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
Deprecate 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
Built-in Functions
Built-in Packages
Database Security
Pragmas
PRAGMA AUTONOMOUS_TRANSACTION
PRAGMA COVERAGE
PRAGMA EXCEPTION_INIT
PRAGMA FIPSFLAG
PRAGMA INLINE
PRAGMA SERIALLY_REUSABLE
PRAGMA SUPPLEMENTAL_LOG_DATA
PRAGMA SUPPRESSES_WARNING_6009
What's New In 19c
What's New In 20c-21c

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
  DBSecWorx