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

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:

image

 

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