RDB/VMS SQL FETCH — VMS SQLdev_2.0
FETCH cursor-name --+------------------->-------------------+--> ;
+--> INTO -+-> parameter -+-------------+
| +----- , <-----+ |
+--> USING DESCRIPTOR descriptor-name --+
Additional information available:
More Information
The FETCH statement advances a cursor to the next row of its result table and retrieves the values from that row. When used in precompiled programs or as part of an SQL module language procedure, FETCH assigns the values from the row to parameters. In interactive SQL, FETCH displays the value of the row on the terminal screen. You can use the FETCH statement in interactive SQL, in precompiled programs, or as part of an SQL module language procedure. You cannot use the INTO and USING clauses in interactive SQL. You must use either the INTO or USING clause in FETCH statements that are embedded in precompiled programs or are part of an SQL module language procedure.
cursor name
The name of the cursor from which you want to retrieve a row.
INTO
The INTO clause specifies a list of parameters to receive the values SQL retrieves from the cursor. The number of parameters in the list must be the same as the number of values in the row of the cursor. (If any of the parameters are host structures, SQL counts the number of variables in that structure when it compares the number of parameters in the INTO clause with the number of values in the row.) The data types of parameters must be compatible with the values of the corresponding column of the cursor row.
USING
Specifies the name of a descriptor that corresponds to an SQL Descriptor Area (SQLDA). In a precompiled program, if you used the INCLUDE statement to insert the SQLDA into your program, the descriptor name is simply SQLDA. Programs that call SQL module language procedures must explicitly declare an SQLDA descriptor and can give it any name. An SQLDA is a collection of variables used only in dynamic SQL. In a FETCH statement, the SQLDA points to a number of parameters SQL uses to receive the values of the row. The number of variables must match the number of values in the row. The data types of parameters must be compatible with the values of the corresponding column of the cursor row.