Page 1 of 3

REGARDING MULTIPLE RECORD READING FROM DB2 USING CICS

PostPosted: Fri Dec 23, 2011 11:58 am
by gabbar
I HAVE A DB2 TABLE WITH 2 ATTRIBUTES
ACCOUNT ID AND ISSUE ID
A PARTICULAR ISSUE ID WILL HAVE MORE THAN 1 ACCOUNT ID ASSOCIATED WITH IT
FOR EXAMPLE THERE IS AN ISSUE ID ABCDEF ... THIS ABCDEF HAS 3 ACCOUNT ID 00000 00001 00002 ASSOCIATED WITH IT
WHICH MEANS ACCOUNT 00000 HOLDS ABCDEF ISSUE AS WELL AS 000001 AND 000002
SO IN MY CICS MAP WHEN THE USER ENTERS A PARTICULAR ISSUE ID ABCDEF I WILL SEARCH THE DB2 TABLE AND THE CURSOR READS 00000 FROM THE TABLE AND LIST HIM AS A PERSON HOLDING THE ISSUE ABCDEF... NOW ON PRESSING ENTER I NEED TO READ THE TABLE AGAIN AND NOW 00000 SHOULD NOT BE CONSIDERED AS IT HAS ALREADY BEEN DISPLAYED INSTEAD 00001 MUST BE READ FROM THE TABLE AND DISPLAYED ON THE CICS SCREEN SIMILARLY NEXT TIME AROUND 00000 AND 00001 MUST BE IGNORED AND 00002 MUST BE DISPLAYED ON THE CICS SCREEN.
I KNOW HOW TO READ THE FIRST RECORD RELATED TO THE ISSUE ID .. BUT THEN THE FIRST RECORD WONT BE IGNORED FROM NEXT TIME AND WILL BE RE READ AGAIN AND AGAIN ...
WHAT IS THE LOGIC TO ACCOMPLISH WHAT I WANT.
THANK YOU

Re: REGARDING MULTIPLE RECORD READING FROM DB2 USING CICS

PostPosted: Fri Dec 23, 2011 12:12 pm
by dick scherrer
Hello and welcome to the forum,

First - TURN OFF the CAPS. This is consider is considered to be shouting and rude on the forum.

Is this a COBOL program?

Re: REGARDING MULTIPLE RECORD READING FROM DB2 USING CICS

PostPosted: Fri Dec 23, 2011 12:14 pm
by dick scherrer
Follow on - do NOT post the same question in multiple topics.

The duplicate has been deleted.

d

Re: REGARDING MULTIPLE RECORD READING FROM DB2 USING CICS

PostPosted: Fri Dec 23, 2011 12:16 pm
by gabbar
Sorry for the caps, i will not repeat it
yes sir it is a cobol program

Re: REGARDING MULTIPLE RECORD READING FROM DB2 USING CICS

PostPosted: Fri Dec 23, 2011 12:30 pm
by dick scherrer
Hello,

Sorry for the caps, i will not repeat it
Cool - thanks :)

Is this a business program or a class exercise?

Suggest you look at a few other COBOL programs that run on your system that have a similar function and follow the way they are implemented. Most systems have standards that need to be followed.

Re: REGARDING MULTIPLE RECORD READING FROM DB2 USING CICS

PostPosted: Fri Dec 23, 2011 12:47 pm
by gabbar
It is a business program, i know how to read records and other things required from the table... the problem i face here is there are only two attributes in the table with one to many relationship and i can read only the first one and then it gets repeated the others related to the same account id are not being read.

Re: REGARDING MULTIPLE RECORD READING FROM DB2 USING CICS

PostPosted: Fri Dec 23, 2011 12:59 pm
by dick scherrer
Hello,

i can read only the first one and then it gets repeated the others related to the same account id are not being read.
You need to change the SELECT to continue from the last row read rather than restarting at the beginning.

Re: REGARDING MULTIPLE RECORD READING FROM DB2 USING CICS

PostPosted: Fri Dec 23, 2011 1:04 pm
by NicC
Why not read all the data for that ID into a cursor and have a loop in the program walking through the cursor displaying each item at a time? Saves going to DB2 each time you want a new item (which turns out to be not the item you need).

Re: REGARDING MULTIPLE RECORD READING FROM DB2 USING CICS

PostPosted: Fri Dec 23, 2011 2:13 pm
by gabbar
thank you , i think i got you.
will implement and reply if i have a problem
:)

Re: REGARDING MULTIPLE RECORD READING FROM DB2 USING CICS

PostPosted: Fri Dec 23, 2011 5:56 pm
by GuyC
NicC wrote:Why not read all the data for that ID into a cursor and have a loop in the program walking through the cursor displaying each item at a time? Saves going to DB2 each time you want a new item (which turns out to be not the item you need).

How would you keep the cursor open in a pseudo-conversational setup?

you could
first time (or when issue-id changes) :
if account-id is character move low-values to hv-account-id
if numeric : move -9999 to hv-account-id (make sure your hv is signed)
select ... where ISSUE_ID = :hv-issue-id and ACCOUNT_ID > :hv-account-id
order by account-id
fetch first 1 row only