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

Is it possible to code "FETCH FIRST <WS-ROWS> ROW


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ravi1

New User


Joined: 27 Apr 2006
Posts: 11

PostPosted: Tue Dec 12, 2006 5:05 pm
Reply with quote

Hi,

Can anyone suggest me whether is it possible to code like

In the last line declaration of Cursor,

FETCH FIRST <WS-ROWS> ROWS ONLY?

where WS-ROWS is declared as PIC s9(4) comp.

Thanks in Advance,
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Tue Dec 12, 2006 5:38 pm
Reply with quote

Hi There,

Yes u can declare it but question is why u want to use it.
Back to top
View user's profile Send private message
ravi1

New User


Joined: 27 Apr 2006
Posts: 11

PostPosted: Tue Dec 12, 2006 5:43 pm
Reply with quote

Hi,

Thanks for your response. This requirement is for Stored Procedure.
User is going to enter required no. of rows from the web.

But I am getting error in DB2 precompilation saying that

WS-ROWS is llegal keyword.

Can u tell me how to solve it?

thanks.
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Tue Dec 12, 2006 5:57 pm
Reply with quote

Hey Ravi,

Just try to use WS-ROWS as host variable i mean by

Code:
FETCH FIRST :WS-ROWS ROWS ONLY



Let us know the result
Back to top
View user's profile Send private message
dharmendra_kp

New User


Joined: 10 Mar 2005
Posts: 33
Location: Lewiston

PostPosted: Tue Dec 12, 2006 6:07 pm
Reply with quote

Also please keep in mind that it is DB2 version dependent.
I mean FETCH FIRST clause is available on V7 onward.
Back to top
View user's profile Send private message
ravi1

New User


Joined: 27 Apr 2006
Posts: 11

PostPosted: Tue Dec 12, 2006 6:18 pm
Reply with quote

It is accepting hard coded values

for ex.

FIRST FIRST 1000 ROWS ONLY.

But it is saying illegal use of keyword if I declare

WS-ROWS as PIC S9(4) COMP.

FETCH FIRST <WS-ROWS> ROWS ONLY.

thanks.
Back to top
View user's profile Send private message
Rajen

New User


Joined: 05 May 2005
Posts: 61

PostPosted: Tue Dec 12, 2006 6:36 pm
Reply with quote

Hi Ravi,
Can you please try adding OPTIMIZE clause at the end of query.

I guess you can try with below mentioned query.

FETCH FIRST <WS-ROWS> ROWS ONLY.

OPTIMIZE FOR <WS-OPTIMIZE-ROWS> ROWS;

Here WS-OPTIMIZE-ROWS is greater than WS-ROWS.

Can you please try with this query and let us know the results.
I dont know if this is the right solution or not but definitely want to give a try.

Thanks,
Rajen.
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 run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts PuTTY - "User is not a surrogate... IBM Tools 5
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
Search our Forums:

Back to Top