Hi,
I have a requirement to retreive rows using cursor from DB2 table using the curosr which is as below:
Select C1, C2,C3, C4, C5, C6..
where C1= :v1
and C2 = :v2
and C3 = ( Select max(C3)
where C1= :v1
and C2 = :v2
and C4 = :v4
)
ORDER BY C1 ASC and C2 DESC.
Lets say the query retrieves 100 rows.
But my program can only handle 50 rows.
so my program in the first instance should retreive first 50 rows in the first instance and the remaining 50 in the next instance.
Could you please help me with this.
How to sort and retrevie rows without using ORDER BY clause
Moderators: Kalicharan, Moderator Group
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
As posted, it will retrieve 100 rows . . ., will it not?Suggtest you try this and see what happens?
Is this running in a program that should process the first 50 and then the next 50?
If so, you need to keep track of "where you are" and on the second time thru, start with the "next" row.
Another way you might consider is using a multi-row fetch.
And why does the topic title say Not to use ORDER BY?
Have a good one
FREE TUTORIALS
Tutorials
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.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page