I have a SQL query that looks like this:
SELECT foo "c0",
bar "c1",
baz "c2",
...
FROM some_table
WHERE ...
In order to apply a limit, and only return a subset of records from this query, I use the following wrapper SQL:
SELECT *
FROM (
SELECT t.*,
ROW_NUMBER() OVER (ORDER BY ...) rnum
FROM (
... original SQL goes here ...
) t
)
WHERE rnum BETWEEN 1 AND 10
My problem is that the original query is selecting over 1000 columns across a large number of joins to other tables. Oracle has an internal limit of 1000 columns per table or view, and apparently the wrapper SQL I'm using to limit the result set is creating a temporary view to which this limit is applied, causing the whole thing to fail.
Is there another method of pagination that doesn't create such a view, or wouldn't otherwise be affected by the 1000 column limit?
I'm not interested in suggestions to break the work up into chunks, not select > 1000 columns, etc., as I'm already fully aware of all of these methods.