DZone
Database Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Database Zone > Marking Out-of-Use Methods

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.

Emrah Mete user avatar by
Emrah Mete
CORE ·
May. 10, 17 · Database Zone · Tutorial
Like (3)
Save
Tweet
1.80K Views

Join the DZone community and get the full member experience.

Join For Free

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.

Mark (designation) PL/SQL dev Inform Session (web analytics) Software

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Container Orchestration Tools Comparison
  • Top 7 Features in Jakarta EE 10 Release
  • How Java Apps Litter Beyond the Heap
  • How To Check for JSON Insecure Deserialization (JID) Attacks With Java

Comments

Database Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo