View previous topic :: View next topic
|
Author |
Message |
esudhakar
New User
Joined: 25 Sep 2006 Posts: 3
|
|
|
|
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 |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
esudhakar
New User
Joined: 25 Sep 2006 Posts: 3
|
|
|
|
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 |
|
|
kgumraj
Active User
Joined: 01 May 2006 Posts: 151 Location: Hyderabad
|
|
|
|
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 |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|