The FETCH function retrieves the next row from an open Connect CDC (SQData) cursor.
FETCH() returns a character value that is typically tested in script logic. If the function encounters an unexpected datastore error, Connect CDC (SQData) sets the job fatal and processing stops.
Important: Connect CDC (SQData) normalizes cursor fetch status for script processing. Do not expect native DB2 SQLCODE values to be returned by
FETCH().Category
Cursor Functions
Syntax
FETCH(cursor_name)Parameters and descriptions
| Parameter | Description |
|---|---|
cursor_name |
Name of an already opened cursor created with CREATE RDBMS CURSOR, CREATE VSAM CURSOR, or CREATE IMS CURSOR. |
Return values
| Value | Description |
|---|---|
'0' |
A row was fetched successfully. The fields in the record named by the cursor DESCRIBED BY clause are populated with the current row. |
'100' |
No row was found or the cursor reached end-of-data. For RDBMS cursors this is the Connect CDC (SQData) normalized not-found result. For VSAM cursors, end-of-file and no-match conditions are normalized to the same value. |
Usage
- Only use the
DESCRIBED BYfields whenFETCH()returns'0'. - When
FETCH()returns'100', there is no current row and the previously fetched values are not cleared automatically, so those fields may still contain data from the prior successful fetch. - Any datastore error other than the normalized no-row condition is treated as a runtime failure. Connect CDC (SQData) does not return arbitrary DB2 SQLCODE values through
FETCH()for script logic.
Example
OPEN(SQDATA_RDBMS_CURSOR)
WHILE FETCH(SQDATA_RDBMS_CURSOR) = '0'
DO
TARGET_ACCOUNT_ID = SQDATA_CURSOR_ROW.ACCOUNT_ID
TARGET_ACCOUNT_STATUS = SQDATA_CURSOR_ROW.ACCOUNT_STATUS
END
CLOSE(SQDATA_RDBMS_CURSOR)