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
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Is it possible to code "FETCH FIRST <WS-ROWS> ROW
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: 1187
Location: Bangalore,India

PostPosted: Tue Dec 12, 2006 5:38 pm    Post subject:
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    Post subject: Re: Is it possible to code "FETCH FIRST <WS-ROWS>
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: 1187
Location: Bangalore,India

PostPosted: Tue Dec 12, 2006 5:57 pm    Post subject:
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    Post subject:
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    Post subject: Re: Is it possible to code "FETCH FIRST <WS-ROWS>
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    Post subject: Re: Is it possible to code "FETCH FIRST <WS-ROWS>
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    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 Job failing with USER = 4093 REASON C... Pradeepa S ABENDS & Debugging 1 Wed May 17, 2017 3:35 pm
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts RC 20 for Address ISPEXEC "ISRED... pkmurali CLIST & REXX 3 Sun Apr 16, 2017 11:30 pm


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