Please suggest me for the following requirement:
I have a file containg different types of records.
emptype emprgn ctrcd
ex: LDC1 NA 0001
LDC2 NA 0001
LDC3 00 NA
Like this I am having some number of reocrds. Here my requirement is to retrieve the data from the db2 tables(same tables for all records) for each set of above records and do the processing.
For this what my thought is :
1.Read the above file into an internal cobol table.
2. declare a cursor and in the where codition give like
ex: where emptype= : ws-emptye(emp-indx)
emprgn= : ws-emprgn(emp-indx)
ctrcd = : ws-ctdcd(emp-indx)
So for each read of records from input file we need to declare the cursor(by keeping this in a loop)
3.after declaring do the process on the retrieved data.
But my doubt is
Can we declare a cursor with Index/subscript in the where condition.
for each set of records we need to declare the cursor. Is this right way?
Read input file: say there are 3 records..
If I do the processing as per your suggestions I think I can only able to retrieve the records from database for 1st input record...
what about the remaining 2 recods..??
read the input file...
Here I will get the 1st record...
1.para to open the cursor
2.Para to fetch the cursor until end of cursor
..here I will get all the records from database...
3.Para to close the cursor
4.perform the read para again ....
If I do the read para again can we able to retrieve the 2 nd n 3rd records data from DB?
Its better to populate your Array fields to Host variables before opening the cursor.
In declare cursor also use Host Variables
Here is the logic.
Read your input file and load in to array(Increment counter while loading)
Set Index to 1.
Perform Counter times
Populate the required Array felds to Host Variables
para to open the cursor
Para to fetch the cursor until end of cursor
Para to close the cursor
Set Index Upby 1.
This is the Basic information.You can manipulate as per your requirement.
Seniors and Moderators Please correct me if i am wrong.