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.