Comparing Arguments to the Parameter List
When you create or register a UDR with CREATE PROCEDURE or CREATE FUNCTION, you declare a parameter list with the names and data types of the parameters that the UDR expects. (Parameter names are optional for external routines written in the C or Java™ languages.) See Routine Parameter List for details of declaring parameters.
User-defined routines can be overloaded, if different routines have the same identifier, but have different numbers of declared parameters. For more information about overloading, see Routine Overloading and Routine Signatures.
If you attempt to execute a UDR with more arguments than the UDR expects, you receive an error.
If you invoke a UDR with fewer arguments than the UDR expects, the omitted arguments are said to be missing. The database server initializes missing arguments to their corresponding default values. This initialization occurs before the first executable statement in the body of the UDR.
If missing arguments have no default values, HCL OneDB™ issues an error.
func( x::integer, y ); -- VALID if only these 2 routines func( x::integer, y, z ); -- have the same 'func' identifier func( x::integer, y ); -- NOT VALID if both routines have func( x::float, y ; -- same identifier and 2 parameters
func( x, y default 1 ) func( x, y default 1, z default 2 )If two registered UDRs that are both called func have the signatures shown above, then the statement
EXECUTE func(100)
invokes func(100,1).You cannot supply a subset of default values using named parameters unless they are in the positional order of the routine signature. That is, you cannot skip a few arguments and rely on the database server to supply their default values.
func( x, y default 1, z default 2 )you can execute:
func( x=1, y=3 )but you cannot execute:
func( x=1, z=3 )