|
Use the CALL statement to execute a user-defined routine (UDR) from within an SPL routine.
The CALL statement invokes a UDR. The CALL statement is identical in behavior to the EXECUTE PROCEDURE and EXECUTE FUNCTION statements, but you can only use CALL from within an SPL routine. You can use CALL in an ESQL/C program or with DB-Access, but only if you place the statement within an SPL routine executed by the program or DB-Access.
If you CALL a user-defined function, specify a RETURNING clause.
If a CALL statement contains more arguments than the called UDR expects, you receive an error.
If a CALL statement specifies fewer arguments than the called UDR expects, the arguments are said to be missing. The database server initializes missing arguments to their corresponding default values. (See CREATE PROCEDURE and CREATE FUNCTION.) This initialization occurs before the first executable statement in the body of the UDR.
If missing arguments do not have default values, the database server initializes the arguments to the value of UNDEFINED. An attempt to use any variable that has the value of UNDEFINED results in an error.
In each UDR call, you have the option of specifying parameter names for the arguments you pass to the UDR. Each of the following examples are valid for a UDR that expects character arguments named t, n, and d, in that order:
The syntax of specifying arguments is described in more detail in Argument.
The RETURNING clause specifies the data variable that receives values that a a called function returns.
The following example shows two UDR calls:
The first routine call (no_args) expects no returned values. The second routine call is to a function (yes_args), which expects three returned values. The not_much() procedure declares three integer variables (i, j, and k) to receive the returned values from yes_args.