informix
Informix Guide to SQL: Syntax
SPL Statements

CALL

Use the CALL statement to execute a user-defined routine (UDR) from within an SPL routine.

Syntax

Element Purpose Restrictions Syntax
data_var Name of a variable that receives the value or values a function returns The data type of data_var must be appropriate for the value the function returns. Identifier, p. 4-205
function Name of the user-defined function to call The function must exist. Database Object Name, p. 4-50
procedure Name of the user-defined procedure to call The procedure must exist. Database Object Name, p. 4-50
routine_var Name of a variable that is set to the name of a UDR The routine_var must have the data type CHAR, VARCHAR, NCHAR, or NVARCHAR. The name you assign to routine_var must be non-null and the name of an existing UDR. Identifier, p. 4-205

Usage

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.

Specifying Arguments

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.

Receiving Input from the Called UDR

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.


Informix Guide to SQL: Syntax, Version 9.2
Copyright © 1999, Informix Software, Inc. All rights reserved