IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Cobol-Db2 Program...suggest me the best way...


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Hyderabad

PostPosted: Mon Aug 11, 2008 11:07 am
Reply with quote

Hi....
Please suggest me for the following requirement:
My 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?

Please suggest If I can do it in some other way.
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 218
Location: India

PostPosted: Mon Aug 11, 2008 12:53 pm
Reply with quote

As per my understanding of your requirement

1. You have an input file
2. For each record of Input file you will get many records from the DB2 Table.

If the above is the case
I think there is no need of using index as loading the input file information in to an array is not required.

Here is the process what i suggest from my side.


Read the input file(Read para)

Perform xxx-para until end of file

xxx-para.
para to open the cursor
Para to fetch the cursor until end of cursor
Para to close the cursor
perform the read para again

Let us know the process that you need to do with the fetched records so that more help can be obtained.
Seniors and Moderators please correct me if i am wrong.
Back to top
View user's profile Send private message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Hyderabad

PostPosted: Mon Aug 11, 2008 1:46 pm
Reply with quote

Hi...

Your understanding is correct..

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...
xxx-para.
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?

Please suggest
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 218
Location: India

PostPosted: Mon Aug 11, 2008 2:57 pm
Reply with quote

Can you post your code??
Back to top
View user's profile Send private message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Hyderabad

PostPosted: Mon Aug 11, 2008 3:43 pm
Reply with quote

Hi....

What u understood is corect...I am giving the explanation here...If u need some more info pls post...

I have input file which contains 3 records( ex:
LDC1 NA 0001
LDC2 NA 0001
LDC3 00 NA
As per the specifications I need to store this input data ito an internal cobol table.


2. Need to retrieve the data from 1 table for each of the above 3 records..

for this
DECLARE LDCSUB_EACT_CUR CURSOR FOR
SELECT EMPNO,
EMPRGN,
CTRCD
FROM LDC_ACTEMP
WHERE
empno=:ws-empno
emprgn=:ws-emprgn
ctrcd=:ws-ctrrgn

Here if we wont give the Indx/subscript then it will retrieve rows only for 1st record...So is thr any other way to do the same processing
Back to top
View user's profile Send private message
sri_mf

Active User


Joined: 31 Aug 2006
Posts: 218
Location: India

PostPosted: Tue Aug 12, 2008 12:20 pm
Reply with quote

Hi Mahi,

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.
end-perform.

This is the Basic information.You can manipulate as per your requirement.

Seniors and Moderators Please correct me if i am wrong.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top