New PL/SQL pragma (12cR2) to deprecate program units – sign of a modern programming language


Bryn Llewellyn (Distinguished Product Manager, Database Division, Oracle) presented at OOW2016 on new features in PL/SQL in Oracle Database 12cR2. One of the features that stood out was a new pragma deprecate that can be added to program units such as functions and procedures inside packages. This pragma is used to mark a program unit at deprecated, which typically means: the program unit is still valid, but has been superseded by a better option and no new dependencies should be created on this deprecated unit. In fact, anyone still relying on this deprecated unit should start to consider using its replacement – especially when the code with the dependence is modified anyway for some reason.

Along with the deprecate marker, it is custom to indicate what the replacement is that should be used instead and ideally some indication of how long the deprecated unit will still be around. The pragma deprecate in PL/SQL can have an associated message that provides such information.

It seems that the pragma is part of the implementation of the unit – so resides inside the package body rather than the public specification – but perhaps I am wrong about that. It should be in the specification, as visible as possible.

At compilation time, any dependency from the compiled code on units marked with pragma deprecate will result in compiler warnings. Compilation will succeed, the compiled unit will be valid yet the programmer and/or automated build system are warned and can decide on some course of action.

This slide is taken from Bryn’s presentation:



The documentation on this mechanism is not available at the time of writing.

About Author

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director and Oracle Developer Champion. Solution architect and developer on diverse areas including SQL, JavaScript, Kubernetes & Docker, Machine Learning, Java, SOA and microservices, events in various shapes and forms and many other things. Author of the Oracle Press book Oracle SOA Suite 12c Handbook. Frequent presenter on user groups and community events and conferences such as JavaOne, Oracle Code, CodeOne, NLJUG JFall and Oracle OpenWorld.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.