Starting in Version 9.7, you can create procedures and specify default values for parameters. When calling procedures, arguments can be assigned to parameters by name, allowing you to pass named arguments in any order.
Starting with Version 9.7 Fix Pack 2, the features of default values and named arguments has been extended to user-defined functions (UDFs).
These enhancements allow for replacing an existing procedure or UDF with added parameters using defaults such that existing invocations of the procedure or UDF do not need to be changed.
You can use the defaultparam.db2 sample program to learn how to use this feature.
CREATE PROCEDURE FOO(parm1 INT DEFAULT -1, parm2 INT DEFAULT -2, parm3 INT DEFAULT -3)
CALL FOO (parm1=>10, parm2=>20, parm3=>30)
The
invocation of FOO is identical to FOO (10, 20, 30).CALL FOO (40)
FOO is invoked using a
value of 40 for parm1 and uses the default values
of -2 for parm2 and of -3 for parm3.CALL FOO (parm3=>30, parm2=>20)
FOO
is invoked using the default value of -1 for parm1,
the value 20 for parm2 and the value 30 for parm3.CALL FOO (40, parm3=>10)
FOO
is invoked using a value of 40 for parm1, the
default value of -2 for parm2, and a value of
10 for parm3.