Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2010
    Posts
    5

    Unanswered: 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

  2. #2
    Join Date
    Jul 2009
    Location
    NY
    Posts
    963
    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

  3. #3
    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!

  4. #4
    Join Date
    Jul 2009
    Location
    NY
    Posts
    963

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •