IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

CURSOR to fetech only first 20 rows.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Prasad Toshniwal
Warnings : 1

New User


Joined: 05 May 2008
Posts: 4
Location: PUNE

PostPosted: Thu Sep 04, 2008 1:37 pm
Reply with quote

Hi,

There is one table containing 50 rows and i want to fetech only first 20 rows.

Is it necessary to use cursor here if yes then what would be my query and declarations if required.

Thanks,
Prasad
Back to top
View user's profile Send private message
anil.csk

New User


Joined: 22 Oct 2007
Posts: 16
Location: Noida

PostPosted: Thu Sep 04, 2008 1:40 pm
Reply with quote

when you go declare the cursor
declare a1 cursor for select .....where ... for fetch first 20 rows.
Back to top
View user's profile Send private message
Prasad Toshniwal
Warnings : 1

New User


Joined: 05 May 2008
Posts: 4
Location: PUNE

PostPosted: Thu Sep 04, 2008 1:44 pm
Reply with quote

Anil,

Thanks. As i am new in DB2 could you please elaborate more on this.

Thanks,
Prasad Toshniwal
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Sep 04, 2008 1:50 pm
Reply with quote

Prasad Toshniwal

Please post in the correct forum.
Topic moved to the correct forum.
Back to top
View user's profile Send private message
anil.csk

New User


Joined: 22 Oct 2007
Posts: 16
Location: Noida

PostPosted: Thu Sep 04, 2008 1:55 pm
Reply with quote

hi,
use the given link that will be use full for you for the cursor understanding.

publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.admin.doc/doc/c0005280.htm
Back to top
View user's profile Send private message
umasankar.eee06

New User


Joined: 04 Sep 2008
Posts: 11
Location: chennai

PostPosted: Mon Sep 08, 2008 10:24 am
Reply with quote

Hi prasad,
U can use OPTIMIZE FOR 20 ROWS in fetch declaration.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts Compare latest 2 rows of a table usin... DB2 1
No new posts How to compare two rows of same table DB2 11
Search our Forums:

Back to Top