For a user-defined function to be executed with the EXECUTE FUNCTION statement, the following conditions must exist:
If EXECUTE FUNCTION specifies fewer arguments than the user-defined function expects, the unspecified arguments are said to be missing. Missing arguments are initialized to their corresponding parameter default values, if these were defined. The syntax of specifying default values for parameters is described in Routine Parameter List.
EXECUTE FUNCTION returns an error under the following conditions:
Unlike Dynamic Server, Extended Parallel Server can invoke a function with missing arguments, but the function might fail if a missing argument causes another error (for example, an undefined value for a variable).
If the function name is not unique within the database, you must specify enough parameter_type information to disambiguate the name. See the section Arguments for additional information about how to specify parameters when invoking a function.
In Dynamic Server, the specific name of an external UDR is valid in some DDL statements, but is not valid in contexts where you invoke the function.
If Dynamic Server cannot resolve an ambiguous function name whose signature differs from that of another routine only in an unnamed-ROW type parameter, an error is returned. (This error cannot be anticipated by the database server when the ambiguous function is defined.)
INTO Clause: .-,-----------------------------------------------------. V | |--INTO----+-data_var--+-------------------------------------+-+-+--| | | (1) | | | '--------+-:---------+--indicator_var-' | | | (2) | | | +--------$--+ | | '-INDICATOR-' | '-data_structure------------------------------------'
Element | Description | Restrictions | Syntax |
---|---|---|---|
data_structure | Structure that was declared as a host variable | Individual elements of structure must be compatible with the data types of the returned values | Language specific |
data_var | Variable to receive the value that a user-defined function returns | See Data Variables. | Language specific |
indicator_var | Program variable to store a return code if the corresponding data_var receives a NULL value | Use an indicator variable if the value of the corresponding data_var might be NULL | Language specific |
You must include an INTO clause with EXECUTE FUNCTION to specify the variables that receive the values that a user-defined function returns. If the function returns more than one value, the values are returned into the list of variables in the order in which you specify them.
If the EXECUTE FUNCTION statement stands alone (that is, it is not part of a DECLARE statement and does not use the INTO clause), it must execute a noncursor function. A noncursor function returns only one row of values. The following example shows a SELECT statement in IBM Informix ESQL/C:
EXEC SQL execute function cust_num(fname, lname, company_name) into :c_num;Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]