Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004

    Question Unanswered: SQL script to start search from a row number and next n number of records

    I am working on a product which has to support multiple databases.
    (Oracle, DB2, Sybase and PostGres). I am using hibernate package which provides multiple database connectivity. My requirement is that
    I should write a SQL Query (select statement) which should start from a record number and should return me the next n number of records from that record. The constraint is that i cannot have the primary key to be a index of the record number and i dont have the option of having another column "index" in the table. Could you please get back if it can be done using sql as it has to support all the four mentioned databases.
    Thank you in advance.

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    perhaps you need to re-think your approach

    relational databases do not use "record numbers"

    the closest you can come is to select some rows, then sort them, and then perform some filtering based on relative positions within the sorted rows

    but note that this filtering comes after the rows have already been selected and sorted | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Sep 2002
    Provided Answers: 1
    This is off the question (Rudy has already answered it nicely), but that Hibernate package gets nicely roasted by Tom Kyte

    Search for hibernate scary (without quotes) which gets 1 hit called "Develop Environment", which talks about Hibernate towards the bottom. I would have given a direct URL, but couldn't get it to work!

Posting Permissions

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