SQL/MX 2.x Reference Manual (H06.04+)

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-71
OPEN Statement
OPEN Statement
Considerations for OPEN
C Examples of OPEN
COBOL Examples of OPEN
The OPEN statement opens a cursor in a host program and establishes the result table
specified by the DECLARE CURSOR statement for the named cursor. It positions the
cursor before the first row of the result table.
In dynamic SQL, the cursor name is provided at execution time. An optional USING
clause provides input parameters for the cursor specification. Otherwise, there is no
difference between the static and dynamic forms of OPEN.
Use OPEN only in embedded SQL programs in C or COBOL.
cursor-name
is an SQL identifier—the name of a cursor. The cursor must be previously declared
and not already open. See Identifiers on page 6-52.
ext-cursor-name
is a value-specification—a character literal or a host variable with character
data type. When OPEN executes, the content of the host variable (if used) gives
the name of the cursor. The cursor must be previously declared and not already
open.
GLOBAL | LOCAL
specifies scope. The default is LOCAL. The scope of a GLOBAL cursor is the SQL
session. The scope of a LOCAL cursor is the module or compilation unit in which
OPEN appears.
OPEN {cursor-name | ext-cursor-name}
[USING {argument-list | descriptor-spec}]
ext-cursor-name is:
[GLOBAL | LOCAL] value-specification
argument-list is:
variable-spec [,variable-spec]...
descriptor-spec is:
SQL DESCRIPTOR descriptor-name
variable-spec is:
:variable-name [[INDICATOR] :indicator-name]
descriptor-name is:
[GLOBAL | LOCAL] value-specification
C/COBOL