The code is not compiling for multi-fetch:
S SQL HOST VARIABLE REFERENCE "VAR-NAME" HAD INVALID SYNTAX OR THE
REFERENCED HOST VARIABLE WAS AN INVALID SQL VARIABLE TYPE. THE STATEME
WAS DISCARDED.
The column "is not null" (primary key).
01 GD-VAR-NAME PIC S9(004) COMP.
01 TABLE-1.
02 XXX OCCURS 10 TIMES.
05 VAR-NAME PIC S9(004) COMP.
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT VAR_NAME
FROM DB2xxx.table-name
FETCH FIRST 28 ROWS ONLY
END-EXEC.
01 TABLE-1.
02 XXX OCCURS 10 TIMES.
05 VAR-NAME PIC S9(004) COMP.
EXEC SQL
DECLARE C1 CURSOR FOR
SELECT VAR_NAME
FROM DB2xxx.table-name
FETCH FIRST 28 ROWS ONLY
END-EXEC.
This works:
EXEC SQL
FETCH C1 INTO :GD-VAR-NAME
END-EXEC
FETCH C1 INTO :GD-VAR-NAME
END-EXEC
But this does not compile, giving the error above:
EXEC SQL
FETCH C1 FOR 10 ROWS INTO :XXX
END-EXEC
FETCH C1 FOR 10 ROWS INTO :XXX
END-EXEC
Could someone help me, please?