问题
Although in Oracle DB its is allowed to parametrize the number of rows that the query can fetch by adding to the query:
select ...
from ...
where ...
and rownum <= @MaximumRecords
I can't add similar condition to acuivalent query running in DB2: It is allowed to add:
select ...
from ...
where ...
fetch first 500 rows only
(where there is fixed number of rows) but not:
select ...
from ...
where ...
fetch first :1 rows only
(:1 == @MaximumRecords)
Is someone aware of a solution/work-around to this problem?
回答1:
I think I found the solution. I just ran this query with a tool that gave a 0 default value to @MaximnumRecords
and apperently DB2 doesn't allow to perform:
"fetch first 0 rows only" in any case - that was the problem.
来源:https://stackoverflow.com/questions/2621420/db2-wont-allow-parameterize-fetch-first-x-rows-only