Q

Best way to read over 700,000 rows of COBOL

I'm using COBOL on a mainframe and am sequentially reading over 700,000 rows. I'm using a table to join to another DB2 table. What is the best way to do this?
If I am reading your question correctly, I think I can offer some guidance. I think you are saying that you are reading one table row by row using a cursor and that cursor returns over 700,000 rows. For each row you are taking a column (or several columns) and using it to drive another SELECT/cursor. That is not good program design. It would be better to use a join between the two tables instead of reading a row and sending it to another SQL statement. For example, convert this pseudo-code:
SELECT x,y,z
FROM    table1
WHERE conditions on table1 columns
LOOP...
   FETCH
   set HOST-VAR = table1.x
   SELECT a,b,c
   FROM table2
   WHERE table2.a = HOST-VAR
   AND     table2 conditions
END LOOP
Change the above to something like this:
SELECT x,y,z,a,b,c
FROM    table1,
             table2
WHERE x = a
AND      table1 conditions
AND      table2 conditions
That will perform much better. If there are circumstances where there are no rows in table2 that will match table1, then you will need to change this join into an outer join.
This was last published in January 2005

Dig Deeper on IBM DB2 management

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchBusinessAnalytics

SearchAWS

SearchContentManagement

SearchOracle

SearchSAP

SearchSQLServer

Close