Rexx & SQL and multiple cursors
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> TSO and ISPF

#1: Rexx & SQL and multiple cursors Author: misi01Location: Stockholm, Sweden PostPosted: Tue Jul 25, 2023 2:27 am
    —
Thought I'd append this since I had to experiment a bit with it to get it working.
Background is I've written a Rexx application that compares a DL/1 database key with it's root and child segments with the equivalent DB2 tables (that do not need to match segment for table).
The example that caused me grief for a while was the following unloaded DL/1 database
Quote:

DFFPB SFPBPNR
DFFPB SFPBFALL
DFFPB SFPBSJP
DFFPB SFPBSJP
DFFPB SFPBSJP
DFFPB SFPBFALL
DFFPB SFPBSJP
DFFPB SFPBSJP
DFFPB SFPBSJP

As can be seen (?), there is a root segment (SFPBPNR), then a child segment (SFPBFALL) which in turn can contain its own children (SFPBSJP).
My idea was to maintain a list of each segment, whether the equivalent DB2 cursor was open and what that cursor number was..
What I hadn't figured on was second SFPBFALL segment. It seems that the db2 descriptor for the second SFPBFALL didn't match that for the previous SFPBSJP, so I was receiving error
Quote:

SQLSTATE = 42806 SQLERRD = -314,0,0,384,1,0 SQLERRP = DSNXROHB SQLERRMC = 1
-° DSNT408I SQLCODE = -303, ERROR: A VALUE CANNOT BE ASSIGNED TO OUTPUT HOST
VARIABLE NUMBER BECAUSE THE DATA TYPES ARE NOT COMPARABLE
DSNT415I SQLERRP = SQL PROCEDURE DETECTING ERROR

on the second SFPBFALL fetch.

"Normally", this wouldn't be a problem, since you've probably only opened one cursor in your Rexx script, but here it was.
The simple solution was to change the code from
Code:

address dsnrexx "execsql fetch c"y" using descriptor :db2"

(where y was the cursor "number" for each segment/table)
to
Code:

address dsnrexx "execsql describe s"y" into :db2"         
address dsnrexx "execsql fetch c"y" using descriptor :db2"

after which the problem disappeared.



MVSFORUMS.com -> TSO and ISPF


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group