INFORMIX
Informix Guide to SQL: Syntax
Chapter 1: SQL Statements
Home Contents Index Master Index New Book

SQL Statements

EXECUTE

Use the EXECUTE statement to run a previously prepared statement or set of statements.

Syntax

Element Purpose Restrictions Syntax

statement id

Identifier for an SQL statement

You must have defined the statement identifier in a previous PREPARE statement. After you release the database server resources (using a FREE statement), you cannot use the statement identifier with a DECLARE cursor or with the EXECUTE statement until you prepare the statement again.

PREPARE, p. 1-541

statement id variable

Host variable that identifies an SQL statement

You must have defined the host variable in a previous PREPARE statement. The host variable must be a character data type.

PREPARE, p. 1-541

Usage

The EXECUTE statement passes a prepared SQL statement to the database server for execution. The following example shows an EXECUTE statement within an INFORMIX-ESQL/C program:

Once prepared, an SQL statement can be executed as often as needed.

If the statement contained question mark (?) placeholders, you use the USING clause to provide specific values for them before execution.For more information, see the "USING Clause".

You can execute any prepared statement except the following:

  • A prepared SELECT statement that returns more than one row
    When you use a prepared SELECT statement to return multiple rows of data, you can use the DECLARE, OPEN, and FETCH cursor statements to retrieve the data rows. In addition, you can use EXECUTE on a prepared SELECT INTO TEMP statement to achieve the same result.

  • A prepared EXECUTE FUNCTION statement for an SPL function that returns more than one row
    When you prepare an EXECUTE FUNCTION statement for a SPL function that returns multiple rows, you need to use the DECLARE, OPEN and FETCH cursor statements just as you would with a SELECT statement that returns multiple rows.

For more information on how to execute a SELECT or an EXECUTE FUNCTION, see "PREPARE".

If you create or drop a trigger after you prepared a triggering INSERT, DELETE, or UPDATE statement, the prepared statement returns an error when you execute it.

Scope of Statement Identifiers

A program can consist of one or more source-code files. By default, the scope of a statement identifier is global to the program, so a statement identifier created in one file can be referenced from another file.

In a multiple-file program, if you want to limit the scope of a statement identifier to the file in which it is executed, you can preprocess all the files with the -local command-line option. See your SQL API product manual for more information, restrictions, and performance issues when you preprocess files with the -local option.

INTO Clause

(1 of 2)

Element Purpose Restrictions Syntax

output descriptor

Quoted string that identifies a system-descriptor area

System-descriptor area must already be allocated.

Quoted String, p. 1-1014

output descriptor variable

Host variable name that identifies the system-descriptor area

System-descriptor area must already be allocated.

Quoted String, p. 1-1014

output
indicator
variable

Host variable that receives a return code if null data is placed in the corresponding output variable

Variable cannot be DATETIME or INTERVAL data type.

Variable name must conform to language-specific rules for variable names.

output
sqlda
pointer

Points to an sqlda structure that defines the data type and memory location of values that correspond to the question-mark (?) placeholder in a prepared statement.

You cannot begin an output sqlda pointer with a dollar sign ($) or a colon (:). You must use an sqlda structure if you are using dynamic SQL statements.

DESCRIBE, p. 1-338

output
variable
name

Host variable whose contents replace a question-mark (?) placeholder in a prepared statement

Variable must be a character data type.

Variable name must conform to language-specific rules for variable names.

The INTO clause allows you to save the return values of the following SQL statements:

  • A prepared singleton SELECT statement that returns only one row of column values for the columns in the select list
  • A prepared EXECUTE FUNCTION statement for an SPL function that returns only one group of values
The INTO clause provides a concise and efficient alternative to more complicated and lengthy syntax. In addition, by placing values into variables that can be displayed, the INTO clause simplifies and enhances your ability to retrieve and display data values. For example, if you use the INTO clause, you do not have to use the PREPARE, DECLARE, OPEN, and FETCH sequence of statements to retrieve values.

Important: If you execute a prepared SELECT statement that returns more than one row of data or a prepared EXECUTE FUNCTION for an SPL function that returns more than one group of return values, you receive an error message. In addition, if you prepare and declare a statement, and then attempt to execute that statement, you receive an error message.
  You cannot select a null value from a table column and place that value into an output variable. If you know in advance that a table column contains a null value, make sure after you select the data that you check the indicator variable that is associated with the column to determine if the value is null.
The following list describes how to use the INTO clause with the EXECUTE statement:

    1. Declare the output variables that the EXECUTE statement uses in its INTO clause.

    2. Use the PREPARE statement to prepare your SELECT or EXECUTE FUNCTION statement.

    3. Use the EXECUTE statement, with the INTO clause, to execute your SELECT or EXECUTE FUNCTION statement.

You can specify any of the following items to store return values from a SELECT or EXECUTE FUNCTION statement before you execute it:

  • A host variable name (if the number and data type of the return values are known at compile time)
  • A system-descriptor area that identifies a dynamically generated descriptor for the value
    E/C
  • An sqlda structure that is a pointer to a dynamically generated descriptor for the value.

Saving Values In Host or Program Variables

If you know the number of return values to be supplied at runtime and their data types, you can define the values that the SELECT or EXECUTE FUNCTION statement returns as host variables in your program. You use these host variables with the INTO keyword, followed by the names of the variables. These variables are matched with the return values in a one-to-one correspondence, from left to right.

You must supply one variable name for each value that the SELECT or EXECUTE FUNCTION returns. The data type of each variable must be compatible with the corresponding return value of the prepared statement.

The following example shows how to use the INTO clause of an EXECUTE statement to execute a singleton SELECT and store the column values in host variables:

EXEC SQL prepare sel1 from
'select fname, lname from customer \
where customer_num =123';

The following example shows how to use the INTO clause to execute a SELECT statement that returns multiple rows of data:

EXEC SQL BEGIN DECLARE SECTION;

int customer_num =100;

char fname[25];

EXEC SQL END DECLARE SECTION;


 for ( ;customer_num < 200; customer_num++)

{

EXEC SQL execute sel1 into :fname using :customer_num;

printf("Customer number is %d\n", customer_num);

printf("Customer first name is %s\n\n", fname);

}

For more information on how to use input parameters, see "USING Clause".

Saving Values in a System-Descriptor Area

If you do not know the number of return values to be supplied at runtime or their data types, you can associate output values with a system-descriptor area. A system-descriptor area describes the data type and memory location of one or more values.

X/O
You can also use an sqlda structure (page 1-391) to supply parameters dynamically. However, a system-descriptor area conforms to the X/Open standards.

To specify a system-descriptor area as the location of output values, use the INTO SQL DESCRIPTOR clause of the EXECUTE statement. Each time that the EXECUTE statement is run, the values that the system-descriptor area describes are stored in the system-descriptor area.

The following example show how to use system-descriptor area to execute prepared statements in INFORMIX-ESQL/C:

The COUNT field corresponds to the number of values that the prepared statement returns. The value of COUNT must be less than or equal to the value of the occurrences that were specified when the system-descriptor area was allocated with the ALLOCATE DESCRIPTOR statement. You can obtain the value of a field with the GET DESCRIPTOR statement and set the value with the SET DESCRIPTOR statement.

For further information, refer to the discussion of the system-descriptor area in the INFORMIX-ESQL/C Programmer's Manual.

Saving Values in an sqlda Structure

E/C
If you do not know the number of output values to be returned at runtime or their data types, you can associate output values from an sqlda structure. An sqlda structure lists the data type and memory location of one or more return values. To specify an sqlda structure as the location of return values, use the INTO DESCRIPTOR clause of the EXECUTE statement. Each time the EXECUTE statement is run, the database server places the returns values that the sqlda structure describes into the sqlda structure.

The following example shows how to use an sqlda structure to execute a prepared statement in INFORMIX-ESQL/C:

The sqld value specifies the number of output values that are described in occurrences of sqlvar. This number must correspond to the number of values that the SELECT or EXECUTE FUNCTION statement returns.

For more information, refer to the sqlda discussion in the INFORMIX-ESQL/C Programmer's Manual.

USING Clause

(1 of 2)

Element Purpose Restrictions Syntax

storage descriptor

Quoted string that identifies a system-descriptor area

System-descriptor area must already be allocated. Make sure surrounding quotes are single.

Quoted String, p. 1-1014

storage descriptor variable

Host variable name that identifies a system-descriptor area

System-descriptor area must already be allocated.

Variable name must conform to language-specific rules for variable names.

storage indicator variable

Host variable that receives a return code if null data is placed in the corresponding data variable. It receives truncation information if truncation occurs.

Variable cannot be DATETIME or INTERVAL data type.

Variable name must conform to language-specific rules for variable names.

storage
sqlda
pointer

Points to an sqlda structure that defines the data type and memory location of values that correspond to the question-mark (?) placeholder in a prepared statement.

You cannot begin storage sqlda pointer with a dollar sign ($) or a colon (:). You must use an sqlda structure if you are using dynamic SQL statements.

DESCRIBE, p. 1-338

storage
variable
name

Host variable whose contents replace a question-mark (?) placeholder in a prepared statement

Variable must be a character data type.

Variable name must conform to language-specific rules for variable names.

The USING clause specifies values that are to replace question-mark (?) placeholders in the prepared statement. Providing values in the EXECUTE statement that replace the question-mark placeholders in the prepared statement is sometimes called parameterizing the prepared statement.

You can specify any of the following items to replace the question-mark placeholders in a statement before you execute it:

  • A host variable name (if the number and data type of the question marks are known at compile time)
  • A system-descriptor area that identifies a dynamically-generated descriptor for the value
    E/C
  • An sqlda structure that is a pointer to a dynamically-generated descriptor for the value

Supplying Parameters Through Host or Program Variables

If you know the number of parameters to be supplied at runtime and their data types, you can define the parameters that are needed by the statement as host variables in your program. You pass parameters to the database server by opening the cursor with the USING keyword, followed by the names of the variables. These variables are matched with prepared statement question-mark (?) parameters in a one-to-one correspondence, from left to right.

You must supply one storage variable name for each placeholder. The data type of each variable must be compatible with the corresponding value that the prepared statement requires.

The following example executes the prepared UPDATE statement in INFORMIX-ESQL/C:

Supplying Parameters Through a System-Descriptor Area

If you do not know the number of parameters to be supplied at runtime or their data types, you can associate input values from a system-descriptor area. A system-descriptor area describes the data type and memory location of one or more values.

X/O
You can also use an sqlda structure (page 1-395) to dynamically supply parameters. However, a system-descriptor area conforms to the X/Open standards.

To specify a system-descriptor area as the location of parameters, use the USING SQL DESCRIPTOR clause of the EXECUTE statement. Each time that the EXECUTE statement is run, the values that the system-descriptor area describes are used to replace question-mark (?) placeholders in the PREPARE statement.

The following example show how to use system-descriptor area to execute prepared statements in INFORMIX-ESQL/C:

The COUNT field corresponds to the number of dynamic parameters in the prepared statement. The value of COUNT must be less than or equal to the value of the occurrences that were specified when the system-descriptor area was allocated with the ALLOCATE DESCRIPTOR statement. You can obtain the value of a field with the GET DESCRIPTOR statement and set the value with the SET DESCRIPTOR statement.

For further information, refer to the discussion of the system-descriptor area in the INFORMIX-ESQL/C Programmer's Manual.

Supplying INFORMIX-ESQL/C Parameters Through an sqlda Structure

E/C
If you do not know the number of parameters to be supplied at runtime or their data types, you can associate input values from an sqlda structure. An sqlda structure lists the data type and memory location of one or more values to replace question-mark (?) placeholders. To specify an sqlda structure as the location of parameters, use the USING DESCRIPTOR clause of the EXECUTE statement. Each time the EXECUTE statement is run, the values that the sqlda structure describes are used to replace question-mark (?) placeholders in the PREPARE statement.

The following example shows how to use an sqlda structure to execute a prepared statement in INFORMIX-ESQL/C:

The sqld value specifies the number of input values that are described in occurrences of sqlvar. This number must correspond to the number of dynamic parameters in the prepared statement.

For more information, refer to the sqlda discussion in the INFORMIX-ESQL/C Programmer's Manual.

Error Conditions with EXECUTE

Following an EXECUTE statement, the sqlca record (see the INFORMIX-ESQL/C Programmer's Manual) can reflect two results:

  • The sqlca record can reflect an exception within the EXECUTE statement.
  • The sqlca structure can also reflect the success or failure of the prepared statement that EXECUTE runs. For example, when an UPDATE ... WHERE ... statement within a prepared object processes zero rows, the database server sets sqlca.sqlcode to 100.
In a database that is not ANSI compliant, if any statement fails to access any rows, the database server returns an SQLCODE value of zero(0).

ANSI
In an ANSI-compliant database, if you prepare and execute any of the following statements, and no rows are returned, the database server returns an SQLCODE value of SQLNOTFOUND (100):

  • INSERT INTO table-name SELECT ... WHERE ...
  • SELECT INTO TEMP ... WHERE ...
  • DELETE ... WHERE
  • UPDATE ... WHERE ...
In a multistatement prepare, if any statement in the preceding list fails to access rows, in either ANSI databases or databases that are not ANSI compliant, the database server returns SQLNOTFOUND (100).

Tip: When you encounter an SQLCODE error, a corresponding SQLSTATE error value might exist. See the GET DIAGNOSTICS statement for information about the SQLSTATE status variable.

References

See the ALLOCATE DESCRIPTOR, DEALLOCATE DESCRIPTOR, DECLARE, EXECUTE IMMEDIATE, GET DESCRIPTOR, GET DIAGNOSTICS, PREPARE, PUT, and SET DESCRIPTOR statements in this manual.

In the Informix Guide to SQL: Tutorial, see the discussion of the EXECUTE statement in Chapter 5.

EXECUTE FUNCTION

Use the EXECUTE FUNCTION statement to execute an SPL function or external function.

Syntax

Element Purpose Restrictions Syntax

SPL variable

A variable created with the DEFINE statement that contains the name of an SPL routine to be executed

The SPL variable must be CHAR, VARCHAR, NCHAR, or NVARCHAR data type.

The name assigned to SPL variable must be non-null and the name of an existing SPL function.

Identifier, p. 1-966

Usage

The EXECUTE FUNCTION statement invokes the named user-defined function, specifies its arguments, and determines where the results are returned. A function is a user-defined routine that returns one or more values. An external function, written in a language other than SPL, returns exactly one value. An SPL function can return one or more values.

You can use EXECUTE FUNCTION to execute an SPL function or an external function. You cannot use EXECUTE FUNCTION to execute any type of user-defined procedure. Instead, use the EXECUTE PROCEDURE statement to execute procedures.

How EXECUTE FUNCTION Works

For a function to be executed with the EXECUTE FUNCTION statement, the following conditions must exist:

  • The qualified function name or the function signature (the function name with its parameter list) must be unique within the name space or database.
  • The function must exist.
  • The function must not have any OUT parameters.
If an EXECUTE FUNCTION statement specifies fewer arguments than the called function expects, the unspecified arguments are said to be missing. Missing arguments are initialized to their corresponding parameter default values, if you specified default values. The syntax of specifying default values for parameters in described in "Routine Parameter List".

The EXECUTE FUNCTION statement returns an error under the following conditions:

  • It specifies more arguments than the called function expects.
  • One or more arguments are missing and do not have default values. In this case, the arguments are initialized to the value of UNDEFINED.
  • The fully qualified function name or the function signature is not unique.
  • No function with the specified name or signature that you specify is found.
  • You use it to try to execute a user-defined procedure.

Function Name

With EXECUTE FUNCTION, you can use either of the following types of names to execute a remote function:

  • If you use a fully qualified function name, the database server determines which function to use based only on the routine type (which is FUNCTION) and the function name.
  • If you use a function signature, the database server uses the function name and its full parameter list during routine resolution to determine which function to use.
For more detailed information, see the Function Name segment on page 1-963.

INTO Clause

Element Purpose Restrictions Syntax

data
variable

A variable that receives the value returned by a function

If you issue this statement within an ESQL/C program, the data variable must be a host variable.

If you issue this statement within an SPL routine, the data variable must be an SPL variable.

If you issue this statement within a CREATE TRIGGER statement, the data variable must be column names within the triggering table or another table.

The name of a receiving variable must conform to language-specific rules for variable names.

For the syntax of SPL variables, see Identifier, p. 1-966.

For the syntax of column names, see Identifier, p. 1-966.

data structure

A structure that has been declared as a host variable

The individual elements of the structure must be matched appropriately to the data type of values being selected.

The name of the data structure must conform to language-specific rules for data structures.

indicator variable

A program variable that receives a return code if null data is placed in the corresponding data variable

This parameter is optional, but you should use an indicator variable if the possibility exists that the value of the corresponding data variable is null.

The name of the indicator variable must conform to language-specific rules for indicator variables.

You must specify an INTO clause with EXECUTE FUNCTION to name the variables that receive the values that the 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 INFORMIX-ESQL/C:

INTO Clause with Indicator Variables

ESQL
You should use an indicator variable if the possibility exists that data returned from the user-defined function statement is null. See the INFORMIX-ESQL/C Programmer's Manual for more information about indicator variables.

INTO Clause with Cursors

If the EXECUTE FUNCTION statement executes a user-defined function that returns more than one row of values, it must execute a cursor function. A cursor function can return one or more rows of values and must be associated with a function cursor to execute.

EXT
To return more than one row of values, an external function must be defined as an iterator function. For more information on how to write iterator functions, see the DataBlade API Programmer's Manual.

SPL
To return more than one row of values, an SPL function must include the WITH RESUME keywords in its RETURN statement. For more information on how to write SPL functions, see Chapter 14 in the Informix Guide to SQL: Tutorial.

E/C
In an INFORMIX-ESQL/C program, use the DECLARE statement to declare the function cursor and the FETCH statement to fetch the rows individually from the function cursor. You can put the INTO clause in the FETCH statement rather than in the EXECUTE FUNCTION statement, but you cannot put it in both. The following INFORMIX-ESQL/C code examples show different ways you can use the INTO clause:

Using the INTO clause in the EXECUTE FUNCTION statement

Using the INTO clause in the FETCH statement

SPL
In an SPL routine, if a SELECT returns more than one row, you must use the FOREACH statement to access the rows individually. The INTO clause of the SELECT statement holds the fetched values. For more information, see the FOREACH statement on page 2-27.

Preparing an EXECUTE FUNCTION...INTO Statement

ESQL
You cannot prepare an EXECUTE FUNCTION statement that has an INTO clause. You can prepare the EXECUTE FUNCTION without the INTO clause, declare a function cursor for the prepared statement, open the cursor, and then use the FETCH statement with an INTO clause to fetch the return values into the program variable(s). Alternatively, you can declare a cursor for the EXECUTE FUNCTION statement without first preparing the statement and include the INTO clause in the EXECUTE FUNCTION when you declare the cursor. Then open the cursor, and fetch the return values from the cursor without using the INTO clause of the FETCH statement.

SPL

Dynamic Routine-Name Specification of SPL Functions

Dynamic routine-name specification simplifies the writing of an SPL function that calls another SPL routine whose name is not known until runtime. To specify the name of an SPL routine in the EXECUTE FUNCTION statement, you can use an SPL variable to hold the routine name, instead of listing the explicit name of an SPL routine.

For more information about how to execute SPL functions dynamically, see Chapter 14 in the Informix Guide to SQL: Tutorial.

References

See the CREATE FUNCTION, CREATE FUNCTION FROM, DROP FUNCTION, DROP ROUTINE, and EXECUTE PROCEDURE statements in Chapter 1 of this manual. Also see the CALL and FOREACH statements in Chapter 2 of this manual.

In the Informix Guide to SQL: Tutorial, see the discussion of writing SPL routines in Chapter 14.

EXECUTE IMMEDIATE

Use the EXECUTE IMMEDIATE statement to perform the functions of the PREPARE, EXECUTE, and FREE statements.

Syntax

Element Purpose Restrictions Syntax

statement variable name

Host variable whose value is a character string that consists of one or more SQL statements

The host variable must have been defined within the program. The variable must be character data type. For additional restrictions, see "EXECUTE IMMEDIATE and Restricted Statements" and "Restrictions on Allowed Statements".

Variable name must conform to language-specific rules for variable names.

Usage

The quoted string is a character string that includes one or more SQL statements. The string, or the contents of statement variable name, is parsed and executed if correct; then all data structures and memory resources are released immediately. In the usual method of dynamic execution, these functions are distributed among the PREPARE, EXECUTE, and FREE statements.

The EXECUTE IMMEDIATE statement makes it easy to execute dynamically a single simple SQL statement, which is constructed during program execution. For example, you could obtain the name of a database from program input, construct the DATABASE statement as a program variable, and then use EXECUTE IMMEDIATE to execute the statement, which opens the database.

The following example shows the EXECUTE IMMEDIATE statement in INFORMIX-ESQL/C:

EXECUTE IMMEDIATE and Restricted Statements

You cannot use the EXECUTE IMMEDIATE statement to execute the following SQL statements.

CLOSE

GET DIAGNOSTICS

CONNECT

GET DESCRIPTOR

CREATE FUNCTION FROM

OPEN

CREATE PROCEDURE FROM

OUTPUT

DECLARE

PREPARE

DISCONNECT

SELECT

EXECUTE

SET CONNECTION

EXECUTE FUNCTION

SET DESCRIPTOR

EXECUTE PROCEDURE (if the SPL routine returns values)

WHENEVER

FETCH

Use a PREPARE statement and either a cursor or the EXECUTE statement to execute a dynamically constructed SELECT statement.

Restrictions on Allowed Statements

The following restrictions apply to the statement that is contained in the quoted string or in statement variable name:

  • The statement cannot contain a host-language comment.
  • Names of host-language variables are not recognized as such in prepared text. The only identifiers that you can use are names defined in the database, such as table names and columns.
  • The statement cannot reference a host variable list or a descriptor; it must not contain any question-mark (?) placeholders, which are allowed with a PREPARE statement.
  • The text must not include any embedded SQL statement prefix or terminator, such as the dollar sign ($), colon (:), or the words EXEC SQL.
  • A SELECT or INSERT statement cannot contain a Collection Derived Table clause. EXECUTE IMMEDIATE cannot process input host variables, which are required for a collection variable. Use EXECUTE or a cursor to process prepared accesses to collection variables.

References

See the EXECUTE, FREE, and PREPARE statements in this manual.

In the Informix Guide to SQL: Tutorial, see the discussion of quick execution in Chapter 5.

EXECUTE PROCEDURE

Use the EXECUTE PROCEDURE statement to execute an SPL procedure or an external procedure.

Syntax

Element Purpose Restrictions Syntax

receiving
variable

A variable that receives the value returned by an SPL function that you execute with EXECUTE PROCEDURE.

If you issue this statement within an ESQL/C program, the receiving variable must be a host variable.

If you issue this statement within an SPL routine, the receiving variable must be an SPL variable.

If you issue this statement within a CREATE TRIGGER statement, the receiving variable must be a column name within the triggering table or another table.

The name of a receiving variable must conform to language-specific rules for variable names.

For the syntax of SPL variables, see Identifier, p. 1-966.

For the syntax of column names, see Identifier, p. 1-966.

SPL variable

A variable created with the DEFINE statement that contains the name of an SPL routine to be executed.

The SPL variable must have the data type CHAR, VARCHAR, NCHAR, or NVARCHAR.

The name you assign to SPL variable must be non-null and the name of an existing routine.

Identifier, p. 1-966

Usage

The EXECUTE PROCEDURE statement invokes the named user-defined procedure and specifies its arguments. A procedure is a user-defined routine that does not return a value. Use EXECUTE PROCEDURE to execute an SPL procedure or an external procedure.

SPL
For backward compatibility with earlier Informix products, INFORMIX-Universal Server continues to support the INTO clause of the EXECUTE PROCEDURE statement to save values that a stored procedure returns. However, Informix recommends that you use EXECUTE PROCEDURE only with procedures and EXECUTE FUNCTION with functions. For more information, see "INTO Clause".

How EXECUTE PROCEDURE Works

For a procedure to be executed with the EXECUTE PROCEDURE statement, the following conditions must exist:

  • The qualified procedure name or the procedure signature (the procedure name with its parameter list) must be unique within the name space or database.
  • The procedure must exist.
If an EXECUTE PROCEDURE statement has fewer arguments than the called procedure expects, the unspecified arguments are said to be missing. Missing arguments are initialized to their corresponding parameter default values, if you specified default values. The syntax of specifying default values for parameters in described in "Routine Parameter List".

The EXECUTE PROCEDURE statement returns an error under the following conditions:

  • It has more arguments than the called procedure expects.
  • One or more arguments are missing and do not have default values. In this case the arguments are initialized to the value of UNDEFINED.
  • The fully qualified procedure name or the procedure signature is not unique.
  • No procedure with the specified name or signature is found.

Procedure Name

With EXECUTE PROCEDURE, you can use either of the following types of names to execute a remote procedure:

  • If you use a fully qualified procedure name, the database server determines which procedure to use based only on the routine type (which is PROCEDURE) and the procedure name.
  • If you use a procedure signature, the database server uses the procedure name and its full parameter list during routine resolution to determine which procedure to use.
For more detailed information, see the Procedure Name segment on page 1-1008.

INTO Clause

SPL
For backward compatibility with earlier Informix products, you can use EXECUTE PROCEDURE to execute a stored procedure that returns a value. To save the return values of a stored procedure, specify an INTO clause of EXECUTE PROCEDURE to name the variables that receive the return values.

If the stored procedure (or SPL 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 stored procedure returns more than one row or a collection data type, you must access the rows or collection elements with a cursor.

For more information on stored procedures of earlier Informix products, see the CREATE PROCEDURE statement.

SPL

Dynamic Routine-Name Specification of SPL Procedures

Dynamic routine-name specification simplifies the writing of an SPL procedure that calls another SPL routine whose name is not known until runtime. To specify the name of an SPL routine in the EXECUTE FUNCTION statement, you can use an SPL variable to hold the routine name, instead of listing the explicit name of an SPL routine.

If the SPL variable names a stored procedure that returns a value, include the INTO clause of EXECUTE PROCEDURE to specify a receiving variable (or variables) to hold the value (or values) that the stored procedure returns.

For more information on how to execute SPL procedures dynamically, see Chapter 14 in the Informix Guide to SQL: Tutorial.

References

See the CREATE PROCEDURE, CREATE PROCEDURE FROM, DROP PROCEDURE, DROP ROUTINE, and EXECUTE FUNCTION statements in Chapter 1 of this manual. Also see the CALL statement in Chapter 2 of this manual.

In the Informix Guide to SQL: Tutorial, see the discussion of writing SPL routines in Chapter 14.




Informix Guide to SQL: Syntax, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.