Presort Oracle table before the Select Query

From: Stewart <smac_at_svbank.com>
Date: 5 Jun 2002 18:24:33 -0700
Message-ID: <c12c9cf6.0206051724.a1cbb96_at_posting.google.com>


I am trying to select a group of records from an Oracle Database. I want to pre-sort it first before selecting it because the recordsets in the database are not in order. The only way I know how to issue a First SELECT and then an INNER SELECT so that the recordsets return in the INNER SELECT is inorder. An Example of it is below.

SELECT and INNER SELECT: to presort the result before select the final recordset.

SELECT DISTINCT id, name, address, areacode, FROM member
WHERE id in (SELECT id from member where areacode >='408' AND areacode
<='415')

AND rownum <6
ORDER BY id ASC

When user clicks next on the page here is a new query:

SELECT DISTINCT id, name, address, areacode, FROM member
WHERE id in (SELECT id from member where areacode >='408' AND areacode
<='415')

AND id>'some number' AND rownum <6
ORDER BY id ASC

I need the INNER SELECT to pre-sort the table in order for the "id>'some number' to work when the user clicks next. If the table is not pre-sorted, then the first 5 resultset returned is not accurate. When the user clicks next, then it just grab the last id of the 5 resultset and append it to the 'some number' for a new query.

I hope this is not too confusing. Is there another way to pre-sort Oracle table first without using the inner select because it's very slow?

Please advise.

Thanks,
Stewart Received on Thu Jun 06 2002 - 03:24:33 CEST

Original text of this message