Dynamic OPEN Statement

The dynamic OPEN statement opens the named cursor by executing the prepared SELECT statement. The preprocessor generates a call to sqldynexec() for this statement.

Following is the syntax for the dynamic OPEN statement:

SYNTAX
EXEC SQL OPEN cursor-name
 [ USING { SQL DESCRIPTOR structure-name | host-var-ref
 [ [ INDICATOR ] ind-var-ref ] , ... } ] ; 

cursor-name

A cursor name that you previously defined in a DECLARE CURSOR statement.

structure-name

If the prepared SELECT statement to which the cursor name indirectly refers has dynamic parameter markers, the structure-name is the name of an SQLDA_T structure that contains the values to be supplied for those parameter markers.

host-var-ref

Host language variable references (including any indicator variables) are used to supply values for dynamic parameter markers, if any, in the prepared statement. These variables must appear in the SQL Declare section of your ESQL application. For more information, see the "Host Language Variables" and "Indicator Variables" sections in this chapter.

ind-var-ref

An indicator variable provides information about a host language variable that is not representable in the host language variable value itself. You declare indicator variables like host language variables in an SQL Declare section, and declare them as C numeric types. Indicator types can be long, short, sqldec, float, or double. For information on declaring host language variables, see the "Host Language Variables" section in this chapter.

When using the SQLDA_T structure, the OPEN statement expects the DATA member of the SQLVAR_T structure for each column to point to the target storage for the data value returned. It also expects the INDICATOR member to point to a long (which you can set to 0 or -1), if the program allocates storage for INDICATOR.

CAUTION: Any bad pointer values in DATA or INDICATOR members can lead to unpredictable application behavior.

For an example of the dynamic ESQL OPEN statement, see Step 8 in the "Executing Dynamic Cursor Specifications" section in this chapter.


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095