1 Reply Latest reply on Jun 28, 2002 8:28 AM by Manimbul Simorangkir

    Selecting fewer records from thousands

    Mark Kent Newbie

      I've searched for this in the forums, but haven't found an answer. Point me to it if I've missed it.
      Using: JBoss 2.4.3 using CMP (soon to be trying JBoss 3.0), Oracle 8.1.6 (w/ thin drivers), Tomcat 3.2.2, Linux 7.1

      Is there a way to select only a few records by specifying a number of records to return and a starting value?

      I'm looking at the "search the forum" URL here in the JBoss forums that seems to support this. i.e. "...&range=10&search=true&start=30" [get 10 results and start at page 4 (result 31)].

      Reason: I have registration records I've created with a unique key string ("XGK4-FL2C-....") for our product. As a test, I created 10,000 records and then waited for a findAll to run for 3 minutes to get them all. The screen only displays the first 10 rows or results and a total result count. I'd like to be able to get the count for the page, but limit the bean to getting a certain number of rows starting at a certain row. Possible?

        • 1. Re: Selecting fewer records from thousands
          Manimbul Simorangkir Newbie

          >> Is there a way to select only a few records by
          >> specifying a number of records to return and a
          >> starting value?
          yes there is,
          it's best to use database feature
          and oracle give that feature
          example:
          we want to select record from table Employee from line 30 to 40 where in this table available 10000 records.
          the SQL statement look like this
          (SELECT * FROM Employee WHERE ROWNUM < 40) minus
          (SELECT * FROM Employee WHERE ROWNUM < 30)

          the result of this SQL statement is 10 records that beginning from line 30 and finish to line 40

          (sorry if syntax not correct, just refer to oracle documentation about the syntax :-) )
          hope this help..

          Note:
          not all database give that feature, another database I know have this feature is PostgreSQL with syntax LIMIT and OFFSET.

          regards,

          Manimbul Simorangkir