I've been testing with GNUCOBOL and found a number of errors.
1) the precompiler generates invalid code for a multi-row cursor even though it completes with a condition code of 0 with 0 errors.
2) the precompiler generates an error when the definition of a host variable array contains an "OCCURS" clause on a VARCHAR column
3) the SQLERRD(3) contains a value of 1 even after a multi-row fetch which returned multiple rows.
4) a DELETE table-name WHERE CURRENT OF cursor-name only deletes 1 row at the last row returned by the cursor, it should delete ALL of the rows returned by the cursor.
I'll attach a source code file for your testing. It is a modified version of the DELET sample program which has been modified to use a ROWSET cursor & fetch followed by a DELETE WHERE CURRENT OF. *** Note that a number of diagnostic displays and SQL statements were added to try to figure out what DB2 was actually doing.
=====> you will need to fix the output of the precompiler before doing a COBOL compile
DELCURAA-Pre.CBL is the source code with embedded SQL
DELCURAA.CBL is the output of the precompiler with 3 fixes applied, look for *CH* in column 7 to find the 3 lines which needed to be removed.
------------------------------
Charles Haatvedt
------------------------------
Original Message:
Sent: Mon March 30, 2020 11:50 AM
From: Shadman Aziz
Subject: MutliRowInsert/MultiRowFetch doesn't precompile
Installed the latest drop s1707130100) for DB2 V11.1 Mod 3 Fixpack 3which indicated it had support for multirowInsert/Fetch support in embedded COBOL applications but when I try to precompile program using IBM PRECOMPILER, I get error indicating no declared properly.
16 SQL0314N The host variable "w2-deptno" is incorrectly declared.
17 SQL0314N The host variable "w2-deptname" is incorrectly declared.
18 SQL0314N The host variable "w2-mgrno" is incorrectly declared.
19 SQL0314N The host variable "w2-admrdept" is incorrectly declared.
Definitions look like this:
01 w2-tbl.
05 w2-deptno pic x(6) occurs 10 times.
05 w2-deptname pic x(20) occurs 10 times.
05 w2-mgrno pic x(5) occurs 10 times.
05 w2-admrdept pic x(6) occurs 10 times.
So when it gets to multiple row INSERT statement, precompiler indicates error:
*exec sql insert into DEPT
* values
* (:w2-deptno
* ,:w2-deptname
* ,:w2-mgrno
*
*SQL4002N "W2-MGRNO" and "W2-DEPTNAME" are undeclared host
*variables that cannot both be used as descriptor names in a
*single SQL statement.
W2-MGRNO,:w2-admrdept
)
for :ws-no-rows rows
not atomic continue on sqlexception
end-exec
Sample code is based on IBM DB2 z/os example program
#Db2