|
|
| Author |
Message |
Prasad Toshniwal Warnings : 1 New User
Joined: 05 May 2008 Posts: 4 Location: PUNE
|
|
|
|
| Prasad Toshniwal wrote: |
If there are 20 rows in one table and i need to retrieve first 7 rows only.How to do this.IS it compulsory to use cursor here and if yes please let me know the query.
Thanks,
Prasad. |
|
|
| Back to top |
|
 |
References
|
|
 |
Anuj D.
Global Moderator
Joined: 22 Apr 2006 Posts: 2159 Location: Phoenix, AZ
|
|
| Back to top |
|
 |
Moved: Thu Sep 04, 2008 7:31 pm by dick scherrer From JCL to DB2 |
dick scherrer
Global Moderator
Joined: 23 Nov 2006 Posts: 8643 Location: 221 B Baker St
|
|
|
|
Hello Prasad,
First - when you have a new question, you should start a new topic for your question rather than reply to some existing topic.
Second - as you will learn if you contnue to work with databases, there is no such thing as "first 7 rows". You might retrieve some 7 rows, but there is nothing automatically "first" about them. If you read the same sequential file 5 times, the first 7 records will always be the first 7. If you read a table 7 times, the first 7 rows may or may not be the same ones each time. |
|
| Back to top |
|
 |
shabir46
New User
Joined: 24 Jan 2008 Posts: 14 Location: Kerala
|
|
|
|
Hi Prasad,
If you want to just retrieve the first 7 rows from a table, you can use the 'FETCH FIRST 7 ROWS ' command to serve the purpose.
Or if you want to do achive the same purpose through a program, then you can use the cursor and use the cursors iteratively to get 7 rows.
Shabir |
|
| Back to top |
|
 |
Anuj D.
Global Moderator
Joined: 22 Apr 2006 Posts: 2159 Location: Phoenix, AZ
|
|
|
|
Hello,
| shabir46 wrote: |
| If you want to just retrieve the first 7 rows from a table, you can use the 'FETCH FIRST 7 ROWS ' command to serve the purpose. |
Without an "ORDER By" clause this query would be just garbage..
Check the links posted before in this thread, you would get the reason behind with details.. |
|
| Back to top |
|
 |
|
|