Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Retrieve 10 rows 4m a TABLE which has 1000 rws using CURSOR?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
samimaktar

New User


Joined: 03 Aug 2009
Posts: 25
Location: Singapore

PostPosted: Sun Oct 25, 2009 1:33 am    Post subject: Retrieve 10 rows 4m a TABLE which has 1000 rws using CURSOR?
Reply with quote

Hi Friends,
1. I want to retrieve 10 rows from a TABLE which has 1000 rows using CURSOR without fetching all the records(1000 rows)?
2. Consider a table has 'm' rows. I want to retrieve 'n' (n<m) rows where we will pass the value of 'n' dynamically? Is it possible to pass value to 'n' dynamically?
Back to top
View user's profile Send private message

dick scherrer

Site Director


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

PostPosted: Sun Oct 25, 2009 3:11 am    Post subject:
Reply with quote

Hello,

1. FETCH the first 10 and then end the process. The other 990. will not be fetched.

2. Yes. You can pick the method to get the value into the program (parm, sysin, vsam file, database table, whatever).
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Sun Oct 25, 2009 3:24 am    Post subject:
Reply with quote

Here again, a little reading of an SQL Reference would probably help you.
FETCH FIRST
Back to top
View user's profile Send private message
ajeshrn

New User


Joined: 25 Mar 2009
Posts: 78
Location: India

PostPosted: Sun Oct 25, 2009 10:14 am    Post subject:
Reply with quote

Hi samimaktar,

Is your requirement like u should be able to fetch first n records dynamically.That means the value of n can vary from time to time?If thats what you are looking for then use a dynamic sql and move what ever value u want to the variable.Just a sample code.I have done this in my aplication program.It works:
Ex:

05 WS-VAR1 CHAR(50)
'SELECT * FROM A.TABLE1 FETCH FIRST'
05 WS-VALN CHAR(02)
05 WS-VAR1 CHAR(20)
'ROWS ONLY'.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Getting -504 Cursor Name GTT-ARTS-CUR... Robin Sulsona DB2 2 Fri Mar 17, 2017 1:43 am
No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm
No new posts Release of Adabas Cursor mohitsethi All Other Mainframe Topics 1 Mon Feb 06, 2017 8:36 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us