I have a function with 5 parameters,
- arguments
p1
, andp2
are mandatory - arguments
p3
,p4
, andp5
are optional and have aDEFAULT
set
The function looks like this,
CREATE FUNCTION test_func(
p1 int,
p2 int,
p3 int DEFAULT 3,
p4 int DEFAULT 4,
p5 int DEFAULT 5
)
RETURNS int AS
$$
SELECT p5;
$$ LANGUAGE sql;
I can invoke it like this,
SELECT test_func(1,2,3,4,5);
test_func
-----------
5
But I would like to allow p3 and p4 to default and invoke it like this,
SELECT test_func(1,2,5);
Is there a way to specify the value for the last optional parameter (p5
) without giving values to the preceding ones (p3
, p4
)? I don't want to hard-code default values for the p3
, p4
in the call for test_func
, because I may need to change their default values in the future.