I have a procedure defined as:
CREATE OR REPLACE PROCEDURE foo (
AS_OF_DATE_IN IN DATE DEFAULT TRUNC(sysdate)-1
) AS ...
Which can be executed in these manners:
-- passes '11-NOV-2011'
exec foo('11-NOV-2011');
--set DEFAULT value (yesterday's date)
exec foo();
--makes things more difficult, as default value isn't set
exec foo(NULL);
What I want to do is:
AS_OF_DATE_IN:=NVL(AS_OF_DATE_IN, TRUNC(sysdate)-1);
but it generates a reassignment error.
Other than wrapping all usages of AS_OF_DATE_IN with NVL(), is there a more-efficient way to handle this situation?
** edit **
I made a fairly stupid mistake–I’m writing a procedure, not a function. The procedure doesn’t return a value.
You can use a local variable inside the function: