View previous topic :: View next topic
|
Author |
Message |
samimaktar
New User
Joined: 03 Aug 2009 Posts: 25 Location: Singapore
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Here again, a little reading of an SQL Reference would probably help you.
FETCH FIRST |
|
Back to top |
|
|
ajeshrn
New User
Joined: 25 Mar 2009 Posts: 78 Location: India
|
|
|
|
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 |
|
|
|