NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
F-3
FETCH Statement
To execute the query again but save typing effort, you can use the FC command,
specifying the relative position of the SELECT command in relation to the current
command, FC:
>> FC -2
>> SELECT SUPPNAME, CITY, STATE FROM INVENT.SUPPLIER
.
+> WHERE SUPPNUM = 4;
. DDDDDDDDDDDDDDDDD
+>;
The first five rows of the table SUPPLIER are listed.
Suppose 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.
FETCH { cursor } { INTO :var [ , :var ] ... }
{ :cursor-var } { USING DESCRIPTOR :sqlda-desc }