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

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-40
FETCH Statement
ext-cursor-name
is a value-specification—a character literal or a host variable with character
data type. When FETCH executes, the content of the host variable (if used) gives
the name of the open cursor.
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
FETCH appears. The containing module must include a DECLARE CURSOR with
the same cursor name.
{USING | INTO} {argument-list | descriptor-spec}
specifies host variables, rowset host variables, or, in the case of a dynamic cursor,
an SQL descriptor area in which to return the values in the result row of the cursor
specification. For a static cursor, the number of row values must be equal to the
number of specified host variables, and the data type of each source value must
be compatible with the data type of its target host variable. The first value in the
result row is assigned to the first host variable, the second value to the second
variable, and so on.
If you use rowset host variables or descriptors with the appropriate rowset fields
set, values from multiple, consecutive rows are moved into the rowset host
variables with a single execution of the FETCH statement.
In static SQL, you use the INTO keyword. In dynamic SQL, you can use either
USING or INTO. The use of the keyword USING is an SQL/MX extension.
:variable-name [[INDICATOR] :indicator-name]
is a variable specification—a host variable or rowset host variable with,
optionally, an indicator variable or rowset indicator variable. A variable name
begins with a colon (:).
The data type of an indicator variable is exact numeric with a scale of 0. If the
data returned in the host variable is null, the indicator parameter is set to a
value less than zero. If character data returned is truncated, the indicator
parameter is set to the length of the string in the database.
INTO argument-list
specifies host variables. The number of row values must be equal to the number of
specified host variables, and the data type of each source value must be
compatible with the data type of its target host variable. The first value in the result
row is assigned to the first host variable, the second value to the second variable,
and so on.
C/COBOL
C/COBOL
C/COBOL
Java