The use of "deprecated" methods, one of the warning mechanisms we are accustomed to from high-level programming languages, is now provided with PL/SQL with Oracle 12c R2. It is now possible to mark a method as deprecated and then notify it when trying to use this method.
Let's see how quickly we can handle this.
First of all, in order to be aware of these warnings that the compiler will generate, we open the following warning codes at the session level:
ALTER SESSION SET PLSQL_WARNINGS = 'ENABLE:(6019,6020,6021,6022)';
When we want to compile or call a method that we will mark as deprecated, we have opened the subroutine to give the required compiler warning. Now let's look at how to mark a method as deprecated:
CREATE OR REPLACE PROCEDURE kare_hesapla (x NUMBER) IS PRAGMA deprecate ( kare_hesapla, 'Bu metod eski. Yeni metod kare_hesapla_yeni.' ); v NUMBER; BEGIN v := x * x; END kare_hesapla; /
As we can see from the sample we made, we reported to the system that the method is an old method with the statement
PRAGMA deprecate. We compile our code with a warning system like the one below.
We marked our sample method as deprecated. Now let's call this method from within another method.
CREATE OR REPLACE PROCEDURE KARE_HESAPLA_2 IS BEGIN KARE_HESAPLA (5); END KARE_HESAPLA_2;
After compiling the code we see, the necessary warning messages were shown to us by the compiler. With this mechanism, we can easily alert software developers about the use of our old methods, and we can easily inform them about the use of new methods.