Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mark PLSQL procedure/function as deprecated

Tags:

oracle

plsql

Some programming tools like C# or Java can mark procedures/functions as deprecated. But Oracle PLSQL is no built in functionality for this. I wonder there is another way to support this feature.

I want them to show like "The PL/SQL compiler warnings about any PL/SQL code being compiled.".

96/43    PLW-06005: inlining of call of procedure 'TEST' was done
like image 577
Ricardo Cardona Ramirez Avatar asked Sep 24 '15 11:09

Ricardo Cardona Ramirez


People also ask

How do you terminate a procedure in PL SQL?

When the EXIT statement is encountered inside a loop, the loop is immediately terminated and the program control resumes at the next statement following the loop.

What does <> mean in Plsql?

It means not equal to.

Is PL SQL outdated?

The answer is that PL/SQL is not growing, but not going away either. Because it is used in the Oracle database, and the Oracle database is a fixture of enterprise systems world-wide, it will outlive you. High-performance batch processing has to happen close to the data, so PL/SQL will continue to rule in this area.

How do you handle no data found exception in PL SQL?

Answer: To prevent the PLSQL code from dropping to the exception code when a record is not found, you'll have to perform a count first to determine the number of records that will be returned. For example: -- Check to make sure that at least one record is returned SELECT COUNT(1) INTO v_count FROM sales.


2 Answers

In Oracle release 12.2, there is a new pragma for this:

pragma deprecate ( deprecated_thing, 'Message to other developers' );

... where deprecated_thing is any PL/SQL identifier. The following things can be deprecated:

  • Subprograms
  • Packages
  • Variables
  • Constants
  • Types
  • Subtypes
  • Exceptions
  • Cursors

For example:

CREATE OR REPLACE PACKAGE old_package AS
PRAGMA DEPRECATE(old_package , ’Package old_package has been deprecated in favor of new_package’);
    PROCEDURE p1;
    PROCEDURE p2;
END old_package;

Anyone trying to compile something that uses whatever you've deprecated will receive a PL/SQL warning in the range of PLW-6019 to PLW-6022.

You can enable these warnings as follows, so that you will see them when you try to compile code:

alter session set plsql_warnings = 'enable:(6019,6020,6021,6022)';

Alternatively, you can set your session to treat these warnings as errors:

alter session set plsql_warnings = 'error:6020';

Or, you can set the object itself to make anyone using it to get an error:

alter package <package with deprecated stuff> compile plsql_warnings = 'error:6020' reuse settings;
like image 136
Matthew McPeak Avatar answered Oct 06 '22 20:10

Matthew McPeak


This is not a supported function of Oracle and the PL/SQL language. You would have to develop a sort of framework that would check variables at the beginning of execution to determine if the code was depreciated however that would all have to be manually handled by development team. This simply is not a feature yet included by Oracle.

like image 38
James Collins Avatar answered Oct 06 '22 21:10

James Collins