Arguments
Use the Argument segment to pass a specific value as input to a routine. Use this segment wherever you see a reference to an argument in a syntax diagram.
Syntax
Element | Description | Restrictions | Syntax |
---|---|---|---|
parameter | A parameter whose value you specify | Must match a name that CREATE FUNCTION or CREATE PROCEDURE statement declared | Identifier |
singleton _select | Embedded query that returns a single value | Must return exactly one value of a data type and length compatible with parameter | SELECT statement |
Usage
The CREATE PROCEDURE or CREATE FUNCTION statement can define a parameter list for a UDR. If the parameter list is not empty, you must enter arguments when you invoke the UDR. An argument is a specific value whose data type is compatible with that of the corresponding UDR parameter.
When
you execute a UDR, you can enter arguments in either of two ways:
- With a parameter name (in the form parameter name = expression), even if the arguments are not in the same order as the parameters
- By position, with no parameter name, where each expression is in the same order as the parameter to which the argument corresponds. (This is sometimes called ordinal format.)
You cannot mix these two ways of specifying arguments within a single invocation of a routine. If you specify a parameter name for one argument, for example, you must use parameter names for all the arguments.
In the following example, both statements are
valid for a user-defined procedure that expects three character arguments, t, d,
and n:
EXECUTE PROCEDURE add_col (t ='customer', d ='integer', n ='newint'); EXECUTE PROCEDURE add_col ('customer','newint','integer') ;