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

Declaring a cobol table with respect to a DB2 Table


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

New User


Joined: 25 Sep 2006
Posts: 3

PostPosted: Wed Jan 03, 2007 5:01 pm
Reply with quote

Hi,

I have one DB2 table...i want load the data from DB2 table to cobol table. i dont know how many rows are there in the db2 table.. while declaring the cobol table i have mention the size of the table... could you please let me know how can i do it.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Wed Jan 03, 2007 6:07 pm
Reply with quote

Hi Esudhakar,

Quote:
while declaring the COBOL table i have mention the size of the table... could you please let me know how can i do it.


Would u please elaborate ur query?
Do u want to know how we can load COBOL table from db2 table? Or u want to know how to give occurrences for COBOL table without knowing number of records?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Wed Jan 03, 2007 6:15 pm
Reply with quote

esudhakar wrote:
I have one DB2 table...i want load the data from DB2 table to cobol table. i dont know how many rows are there in the db2 table.. while declaring the cobol table i have mention the size of the table... could you please let me know how can i do it.
Do you want to know how many rows you will need in the cobol table at the time of compile?
Or do you want to know how many rows you will need at the time of the select (runtime)?
Back to top
View user's profile Send private message
esudhakar

New User


Joined: 25 Sep 2006
Posts: 3

PostPosted: Thu Jan 04, 2007 11:50 am
Reply with quote

Do u want to know how we can load COBOL table from db2 table? Or u want to know how to give occurrences for COBOL table without knowing number of records?

I want to know both ways...
Back to top
View user's profile Send private message
kgumraj

Active User


Joined: 01 May 2006
Posts: 151
Location: Hyderabad

PostPosted: Fri Jan 05, 2007 11:02 am
Reply with quote

Hi,

Use this query in your program before fetching the information from the table

Select count(*) into :WS-VAR from tablea;

you can then declare the variable table as

01 tablea.
02 rowa occurs 1 to 100000 depending on ws-var
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Fri Jan 05, 2007 7:00 pm
Reply with quote

This still limits you to 100000 rows. COBOL, unlike PL/I and other languages, does not support dynamic array allocation.

If that's what you need in COBOL, try this multi-step process:

1. in program1, do the count as above, and then generate your actual program, perhaps from a template file, replacing the OCCURS upper bound with your count, writing the generated program2 to a dataset
2. feed program2 into a compile/link step
3. execute program2, which is assured of having the correct table size assuming that in this very short time no table changes would have increased the count

Note that certain installations frown on generating production code as it has not passed through change-control procedures.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jan 05, 2007 7:10 pm
Reply with quote

Phrzby Phil wrote:
This still limits you to 100000 rows. COBOL, unlike PL/I and other languages, does not support dynamic array allocation.
IIRC, not natively, but GETMAINs could be called on behalf of the COBOL program, couldn't they? That should allow for than 100000 rows, wouldn't it?
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Jan 05, 2007 11:18 pm
Reply with quote

Calling getmain is a method that will allow for far greater memory allocations than native Cobol will allow, however then you may have to get into maintaining a ?linked list?, calculating subscript offsets and running the linked list chain to find the record your looking for. The overhead of doing this usually offsets the pluses; however, there is a place for it.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Jan 06, 2007 12:48 am
Reply with quote

Hello,

When the data is loaded from the database to the COBOL table, what wil the next process(es) be?

Depending on your requirements, you may be able to create a temporary database table that is customized (situation specific keys and only the columns you need for the "table") to meet you needs.

Also, depending on your requirements, you may be able to process directly against the original database table.

If you post some more info, we will be better able to help.
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 Load new table with Old unload - DB2 DB2 6
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 Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top