Results 1 to 8 of 8
  1. #1
    Join Date
    Sep 2003
    Posts
    4

    Unanswered: Equivalence of 'set rowcount xx'?

    Hi all,

    I am using db2 version 5 and I have to set rowcount for a select query.
    I have tried 'fetch first' or 'optimize for' clauses and row_count() function but I got error messages for all. I think these are not supported in version 5.


    Is there anyone who can assist me?

    regards,
    mel

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    I doubt that "optimize for n rows" is what you want since it has no effect on the results returned. This clause is most commonly used to prevent sequential prefetch when not all rows of a cursor will be fetched.

    What you probably want is:
    FETCH FIRST n ROWS ONLY
    which goes after the ORDER BY clause. But I don't know if it is supported in version 5. You did not mention which DB2 platform you are working with.
    Last edited by Marcus_A; 09-11-03 at 07:14.

  3. #3
    Join Date
    Sep 2003
    Posts
    4
    I am working with DB2 on mainframe. In fact, 'Fetch first n rows only' is what I want but it is not supported in version 5. I don't know what can be done instead of 'fetch first' clause.

    Thanks

  4. #4
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Is this an applicaiton program with embedded SQL or some kind of query tool. Please be specific.

  5. #5
    Join Date
    Sep 2003
    Posts
    4
    I hope I don't misunderstand you. I'll run query from a visual C++ program, but just now I am trying to run it by db2 command center.

  6. #6
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    When you said DB2 on the mainframe, do you mean OS/390 operating system?

    If you use embedded SQL you can declare a cursor and only fetch the rows (one at a time) that you want. If you are not using a cursor, I don't have any solution.

  7. #7
    Join Date
    Sep 2003
    Posts
    3

    Re: Equivalence of 'set rowcount xx'?

    Hello,

    have you tried row_number() over() ?!
    (row number can be set in an update also)

    I don't know if it runs on version 5... :-/

    Damien

  8. #8
    Join Date
    Sep 2003
    Posts
    4

    Re: Equivalence of 'set rowcount xx'?

    yes, i tried but it does not run on version 5 too

Posting Permissions

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