Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Pune

PostPosted: Mon Aug 11, 2008 11:07 am    Post subject: Cobol-Db2 Program...suggest me the best way...
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: 216
Location: India

PostPosted: Mon Aug 11, 2008 12:53 pm    Post subject: Reply to: Cobol-Db2 Program...suggest me the best way...
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: Pune

PostPosted: Mon Aug 11, 2008 1:46 pm    Post subject:
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: 216
Location: India

PostPosted: Mon Aug 11, 2008 2:57 pm    Post subject: Reply to: Cobol-Db2 Program...suggest me the best way...
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: Pune

PostPosted: Mon Aug 11, 2008 3:43 pm    Post subject:
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: 216
Location: India

PostPosted: Tue Aug 12, 2008 12:20 pm    Post subject: Reply to: Cobol-Db2 Program...suggest me the best way...
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 13 Tue Dec 06, 2016 8:30 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us