Cobol program to get data from Large table

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
Posts: 45
Joined: Tue Jun 15, 2010 3:07 pm

Cobol program to get data from Large table

Post by sivasaras » Wed Sep 21, 2016 5:54 pm

I have a table having 7 million records but I want to get only the 2016 data for the employees having the grade from 1 TO 100 .
Is that possible to get total count of each grade through a DB2 query.

I have a program which I have to run 100 times to get the total count for a grade.

Is there any simple way to extract from table.

Please suggest your thoughts.

Posts: 20
Joined: Sun Apr 18, 2010 11:51 pm
Location: St. Cloud, Minnesota, USA

Post by chaat » Sat Sep 24, 2016 11:44 am

declare grade_count cursor for
select grade, count(*)
from db2.table
where grade between 1 and 100
group by grade

this cursor will return 100 rows with the grade and the count for that grade.
Chuck Haatvedt

email --> clastnameatcharterdotnet

(replace lastname, at, dot with appropriate

Posts: 2
Joined: Thu Mar 15, 2018 12:35 pm

Post by Genforst » Thu Mar 15, 2018 12:43 pm

Your comments make me even more experienced and talk to my friends.

Post Reply


Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Mainframe Interview questions

Other References
Mainframe Tools and others