Previous Topic: EXECUTE PROCEDURENext Topic: Description


FETCH

This SQL statement can be executed in the following ways:

Through the CA Datacom Datadictionary Interactive SQL Service Facility (interactive)

In an application program prepared using a CA Datacom/DB SQL Preprocessor (embedded)

By using CA Dataquery (SQL & Batch Modes)

FETCH

 

YES

 

Note: YES indicates a valid execution method for this statement. For information about the access rights required to execute this statement, see the CA Datacom/DB Database and System Administration Guide.

The FETCH statement positions a cursor on the next row of its result table and assigns the value of that row to host variables. You may use multiple FETCH statements referencing the same cursor. The host variables in the INTO list are matched by position to SELECT list expressions. The INTO list may FETCH a leading subset of the SELECT list expressions. However, unless the plan has SQLMODE=DB2, the FETCH statement that appears first in the host program must have the same or greater number of host variables. Also, although each FETCH statement may reference different host variables, unless the plan has SQLMODE=DB2, they must have the same data type, length, precision, and scale.

Following is the syntax diagram for the FETCH statement:

                               ┌─ , ─────────────┐  
►►─ FETCHcursor-name ─┬─ INTO ─▼─ host-variable ─┴────────┬───────────────────►◄
                      └─ USING DESCRIPTORdescriptor-name ─┘