SQL/MP Reference Manual

HP NonStop SQL/MP Reference Manual523352-013
F-3
FETCH Statement
. DDDDDDDDDDDDDDDDD
+>;
The first five rows of the table SUPPLIER are listed.
Suppose that you have executed several commands since you entered the
SELECT command. You can either use the HISTORY command to determine the
SELECT command number, or you can enter:
>> FC SEL
If the history buffer contains several SELECT commands, you must be more
specific; for example, FC SELECT SUPP.
To edit and reexecute the command numbered 14 in the history buffer, enter:
>> FC 14
FETCH Statement
FETCH is a DML and dynamic SQL statement that returns a value for each column in
the next row of the result table defined by the cursor, leaving the cursor positioned at
that row. FETCH can be used only in host programs.
cursor
is the name of an open cursor.
:cursor-var
(dynamic SQL only) is a host variable of SQL type CHAR or VARCHAR that stores
the name of an open cursor.
INTO :var [ , :var ] ...
identifies one or more host variables to receive values. FETCH returns one
SELECT item per host variable. The data type of each variable must be compatible
with the data type of the corresponding SELECT column.
Use this option in dynamic SQL if you know the number and data types of the
returned columns.
USING DESCRIPTOR :sqlda-desc
(dynamic SQL only) is a host variable containing an SQLDA descriptor that
describes a list of memory locations (not always declared host variables) into
which corresponding SELECT columns are copied.
FETCH { cursor } { INTO :var [ , :var ] ... }
{ :cursor-var } { USING DESCRIPTOR :sqlda-desc }