Search code examples
oracle11goracle12coracle19c

Skip arguments when executing functions in oracle


Simple question. I have a function as below

create or replace function f_blah (argfirst number default 5, argsecond number default 5) 
return number
AS

v_value number;
Begin
v_value := argfirst + argsecond;
return v_value;
END;

here are the results of my execution.

Select f_blah(1) from dual

result 6

Select f_blah() from dual

result 10

how to execute the function by giving the second argument alone ?


Solution

  • You can use keyword/value notation with Association Opeator i.e., specify the argument name along with value by using =>

    SELECT f_blah(argsecond=>4) FROM DUAL;
    

    Output will be 9

    Demo