Quote:
Originally posted by marist89
Wow! What a great way to write 200 lines of code when one query will do!
Too, too funny, Jeff!! :D
Pauliemacc, I'm afraid Jeff is right. Why would you want to go through all that PL/SQL when you can do it in SQL? On top of that, the PL/SQL version will be slower. Feel free to time them if you don't believe me. Depending on the exact query, the SQL solution can be *much* faster, but regardless of the query, it will never be slower than the PL/SQL code.
Quote:
Originally posted by akatsari
can you please explain how the INNER and OUTER works? Where can I find documentation on these?
INNER and OUTER are just aliases for the in-line views I created. They only contribute to the readability of the statement, not the functionality. The functionality resides in the structure of the statement and the use of ROWNUM.
Quote:
Originally posted by akatsari
Also in your example, how would the statement look the 2nd time you would call it to get the next chunk?
All you have to do is change the Row numbers you want:
Code:
SELECT
OUTER.C1
FROM
(
SELECT
INNER.C1,
ROWNUM
AS QUERY_ROWNUM
FROM
(
SELECT
C1
FROM
TABLE1
ORDER BY
C1
) INNER
WHERE
ROWNUM < 40
) OUTER
WHERE
OUTER.QUERY_ROWNUM >= 21
And finally, we have:
Quote:
Originally posted by rswamin
SELECT * from ( SELECT Rownum rn, tab1.* FROM tab1 )
WHERE rn between lower_value and Upper_value;
First, I'm not sure why you felt the need to answer a question that has already been answered - especially with almost exactly the same solution. Regardless, I feel the need to comment on this solution because, while it is *almost* exactly the same, it does not support the same functionality that my solution does. Your solution does not support an ORDER BY, which is almost always required in a windowing situation.
Hope that clears up everything. Again, for more information, search on WINDOW ROWNUM in this forum.
- Chris
[Edited by chrisrlong on 02-11-2002 at 10:17 AM]