ALLBASE/SQL Reference Manual (36216-90216)

424 Chapter11
SQL Statements E - R
FETCH
FETCH
The FETCH statement advances the position of an opened cursor to the next row of the
active set and copies selected columns into the specified host variables or data buffer. The
row to which the cursor points is called the current row.
Scope
Application Programs Only
SQL Syntax
[BULK] FETCH
CursorName
{INTO
HostVariableSpecification
USING { [SQL] DESCRIPTOR {SQLDA
AreaName
}
HostVariableSpecification
} }
Parameters
BULK is specified in an application program to retrieve multiple rows with a
single execution of the FETCH statement. After a BULK FETCH statement,
the current row is the last row fetched.
BULK can be specified with the INTO clause (for a statically executed
cursor), but
not
with the USING clause (for a dynamically executed
cursor).
BULK is disallowed in a procedure.
CursorName
identifies a cursor. The cursor's active set, determined when the cursor
was opened, and the cursor's current position in the active set determine
the data to be returned by each successive FETCH statement.
INTO The INTO clause defines where to place rows fetched for a statically
preprocessed SELECT or EXECUTE PROCEDURE statement.
USING The USING clause defines where to place rows fetched for a dynamically
preprocessed SELECT or EXECUTE PROCEDURE statement, or for a
statically preprocessed EXECUTE PROCEDURE statement with an unknown
format.
HostVariableSpecification
identifies one or more host variables for holding and
describing the row(s) in the active set.
When used with the INTO clause, the syntax of
HostVariableSpecification
depends on whether the BULK option is
specified. If BULK is specified,
HostVariableSpecification
identifies an
array that holds the rows fetched. If BULK is not specified, the host variable
declaration identifies a list of individual host variables. The syntax of BULK
and non-BULK variable declarations is shown in separate sections below.
The USING clause with a
HostVariableSpecification
allows non-BULK