Version 6.7.3

FETCH

Function

The FETCH statement positions the cursor on a row within the resultant table and makes the values of that row available to the application program.

Invocation
 

Embedded Mode P

Dynamic Mode  

Interactive Mode  

 

Syntax

fetch_statement.jpg 

cursor_identifier

Identifies the cursor to be used in the FETCH operation.

host_variable_identifier

A valid single host variable identifier. It must have been defined in the application program according to the host language rules.  

The value of the host variable must be a valid cursor identifier. A host variable can be used as cursor identifier only if the cursor is a dynamically declared cursor.

host_variable_specification

A valid host variable specification. It must reference a structure and must have been defined in the application program according to the host language rules.  

USING_clause

 Defines an SQL descriptor area used to receive data from the associated dynamic cursor.  

 

Description

The FETCH statement performs two functions: it moves the cursor in the resultant table from top to bottom, one row at a time, and makes the relevant values of a row available to the application program according to the specification of the INTO clause or the USING clause. The mechanism used when the USING clause has been specified in USING Clause .

The FETCH statement changes the position of the cursor as follows:

Limitations

ANSI Specifics

An INTO clause is mandatory, the USING clause must not be used. Only single host variable specifications are permitted.

Adabas SQL Gateway Embedded SQL Specifics

 

The OPEN statement and the FETCH statement can be in different compilation units (see also DECLARE CURSOR).

 

Example

The following example fetches data from a cursor and places the data into three host variables.

 

FETCH cursor_id

    INTO    :host_var1,

        :host_var2,

        :host_var3 ;

Top of page