Hi Craig,
I am afraid you cannot call a function by specifying the first and last paramter to accept default values.
You can only give first set of default parameters and miss the later ones that will take the default parameters itself.
But there is a workaround if create a wrapper function that calls your desired function using named associations.
Consider a function below
Code:
CREATE OR REPLACE FUNCTION c_test (P_deptno NUMBER DEFAULT 10 ,
p_JOB VARCHAR2 DEFAULT 'CLERK' )
RETURN NUMBER
IS
max_sal NUMBER;
BEGIN
SELECT MAX (sal)
INTO max_sal
FROM emp
WHERE deptno = p_deptno AND p_job = p_job;
RETURN max_sal;
END;
/
I will run following queries
Code:
select c_test(10) from dual;
/
C_TEST(10)
----------
5000
1 row selected.
Code:
select c_test() from dual;
/
C_TEST()
----------
5000
1 row selected.
Code:
select c_test(default) from dual;
/
this results in error
WORKAroundCode:
create or replace function d_test(pjob varchar2 default 'CLERK')
return number is
begin
return c_test(p_job=>pjob);
end;
select d_test('CLERK') from dual;
Hope it solves your problem