Search notes:

Oracle PL/SQL: PRAGMA DEPRECATE

Create a package specification with a deprecated procedure (prc_1) …
create or replace package tq84_pkg_a as

    procedure prc_1; pragma deprecate(prc_1, 'Don''t use tq84_pkg_a.prc_1, use prc_2');
    procedure prc_2;

end tq84_pkg_a;
/
Github repository Oracle-patterns, path: /PL-SQL/pragma/deprecate/pkg_a.pks
… along with its body:
create or replace package body tq84_pkg_a as

    procedure prc_1 is begin
        null;
    end prc_1;

    procedure prc_2 is begin
        null;
    end prc_2;

end tq84_pkg_a;
/
Github repository Oracle-patterns, path: /PL-SQL/pragma/deprecate/pkg_a.pkb
Create another package …
create or replace package tq84_pkg_b as

    procedure run;

end tq84_pkg_b;
/
Github repository Oracle-patterns, path: /PL-SQL/pragma/deprecate/pkg_b.pks
… that is using the deprecated procedure.
create or replace package body tq84_pkg_b as

    procedure run is
    begin
        tq84_pkg_a.prc_1;
    end run;

end tq84_pkg_b;
/
Github repository Oracle-patterns, path: /PL-SQL/pragma/deprecate/pkg_b.pkb
Enable PL/SQL warnings (specifically 6020) and recompile the package:
alter session set plsql_warnings='enable:(6019, 6020, 6021, 6022)';
alter package tq84_pkg_b compile;
--
-- SP2-0809: Package altered with compilation warnings
Github repository Oracle-patterns, path: /PL-SQL/pragma/deprecate/recompile.sql
show errors:
show errors package body tq84_pkg_b;

-- LINE/COL ERROR
-- -------- -----------------------------------------------------------------
-- 5/9      PLW-06020: reference to a deprecated entity: PRC_1 declared in
--          unit TQ84_PKG_A[3,15].  Don't use tq84_pkg_a.prc_1, user prc_2
Github repository Oracle-patterns, path: /PL-SQL/pragma/deprecate/show-errors.sql
Select errors from user_errors:
select
   name,
   type,
   text
from
   user_errors
where
   message_number = 6020;
Github repository Oracle-patterns, path: /PL-SQL/pragma/deprecate/user_errors.sql

Index