FOREACH - connect_cdc_sqdata - Latest

Connect CDC (SQData) Apply engine

Product type
Software
Portfolio
Integrate
Product family
Connect
Product
Connect > Connect CDC (SQData)
Version
Latest
ft:locale
en-US
Product name
Connect CDC (SQData)
ft:title
Connect CDC (SQData) Apply engine
Copyright
2026
First publish date
2000
ft:lastEdition
2026-08-03
ft:lastPublication
2026-08-03T15:57:37.298309
L1_Product_Gateway
Integrate
L2_Product_Segment
Data Integration
L3_Product_Brand
Precisely Connect
L4_Investment_Segment
Application Data Integration
L5_Product_Group
ADI - Connect
L6_Product_Name
Connect CDC

The FOREACH function iterates over an Connect CDC (SQData) cursor and executes a statement body once for each fetched row.

When FOREACH() is used with a cursor, Connect CDC (SQData) maps the input arguments to the cursor USING record, opens the cursor, fetches rows until end-of-data, runs the statement body for each row, and closes the cursor automatically.

Tip: FOREACH() also supports iteration over HASH variables. This topic describes cursor usage.

Category

Cursor Functions

Syntax

FOREACH(cursor_name [, value_1 [, value_2 ...]]) statement_body

Parameters and descriptions

Parameter Description
cursor_name Name of a cursor created with CREATE RDBMS CURSOR, CREATE VSAM CURSOR, or CREATE IMS CURSOR.
value_1, value_2, ... Optional values mapped in order to the fields of the record named in the cursor USING clause.
statement_body The Connect CDC (SQData) statement executed once for each row fetched successfully.

Usage

  • For cursor processing, FOREACH() is a compact alternative to explicit OPEN(), FETCH(), and CLOSE() logic.

    For best results:
    • The values supplied in FOREACH() should match the number and order of the fields in the cursor USING record.
    • The record named in the cursor DESCRIBED BY clause should match the number, order, and compatible types of the columns returned by the cursor.
    • The statement body should read the DESCRIBED BY fields populated by the current fetch.
  • If the cursor reaches end-of-data, iteration ends normally. Any other open or fetch failure is treated as a runtime failure.

Example

CREATE RDBMS CURSOR AS SQDATA_RDBMS_CURSOR WITH
        /+
        SELECT ACCOUNT_ID, ACCOUNT_STATUS
        FROM SQDATA_LOOKUP_SOURCE
        WHERE ACCOUNT_ID = ? AND REGION_CODE = ?
        +/
        DESCRIBED BY SQDATA_CURSOR_ROW
        USING SQDATA_CURSOR_INPUT
        ;
        
        FOREACH(SQDATA_RDBMS_CURSOR, SQDATA_CURSOR_INPUT.ACCOUNT_ID, SQDATA_CURSOR_INPUT.REGION_CODE)
        DO
        TARGET_ACCOUNT_ID     = SQDATA_CURSOR_ROW.ACCOUNT_ID
        TARGET_ACCOUNT_STATUS = SQDATA_CURSOR_ROW.ACCOUNT_STATUS
        END