Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Implement 'default on null' clause for PL/SQL parameters

William RobertsonMay 29 2017 — edited May 8 2023

As of Oracle 12.1 we have the useful default on null clause of CREATE/ALTER TABLE for specifying a value to be substituted for null when inserting a row. This is an improvement over the plain default as it allows us to control what happens when a null is passed, rather than just when the column is left out of the INSERT statement.

I would like equivalent semantics to be added to PL/SQL procedure and function parameter declarations, e.g:

procedure do_something
    ( p_someparam date default on null sysdate );

With the current syntax we can never be sure we have a value for p_someparam even when there is a default value declared, so often we have to declare a local constant and assign it using nvl(p_someparam,sysdate), thus repeating the default. It should be simple for the PL/SQL engine to do this for us.

Comments
Post Details
Added on May 29 2017
4 comments
5,002 views