Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Marking Out-of-Use Methods

DZone's Guide to

Marking Out-of-Use Methods

With Oracle 12c R2, it is now possible to mark a method as deprecated and then notify it when trying to use this method. Learn how to do it.

· Database Zone
Free Resource

Whether you work in SQL Server Management Studio or Visual Studio, Redgate tools integrate with your existing infrastructure, enabling you to align DevOps for your applications with DevOps for your SQL Server databases. Discover true Database DevOps, brought to you in partnership with Redgate.

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.

Image title

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;

Image title

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.

It’s easier than you think to extend DevOps practices to SQL Server with Redgate tools. Discover how to introduce true Database DevOps, brought to you in partnership with Redgate

Topics:
database ,oracle ,tutorial ,deprecation

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}