If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Paramertize Fetch First n Rows Only

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-13-10, 11:05
snowcl16 snowcl16 is offline
Registered User
 
Join Date: Oct 2010
Posts: 5
Paramertize Fetch First n Rows Only

I'm using iSeries v5r4.

I have a proc:

SELECT *
FROM TABLE
FETCH FIRST @PARAM ROWS ONLY

But that does not work.

I've tried

SELECT *
FROM TABLE
FETCH FIRST || @PARAM || ROWS ONLY

Which doesn't work either. Anyone had success with this? I'd prefer not to use ROW_NUMBER ( ) OVER ( ) if possible.

Thanks
Reply With Quote
  #2 (permalink)  
Old 10-13-10, 11:51
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
1. Host variable @PARAM has to be declared as integer
2. Also, in procedure, you can create the dynamic query and execute later from cursor

Lenny
Reply With Quote
  #3 (permalink)  
Old 10-13-10, 12:53
snowcl16 snowcl16 is offline
Registered User
 
Join Date: Oct 2010
Posts: 5
Quote:
Originally Posted by Lenny77 View Post
1. Host variable @PARAM has to be declared as integer
2. Also, in procedure, you can create the dynamic query and execute later from cursor

Lenny
1. It is!
2. Could you give an example please?

Thanks!
Reply With Quote
  #4 (permalink)  
Old 10-13-10, 13:08
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
Lightbulb

Quote:
Originally Posted by snowcl16 View Post
1. It is!
2. Could you give an example please?

Thanks!
You have an example. This is your procedure. Any additional information in manuals:

http://publib.boulder.ibm.com/epubs/pdf/dsnsqj15.pdf
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On