DB2: Won't allow parameterize fetch first X rows only

Posted by Guy Roth on Stack Overflow See other posts from Stack Overflow or by Guy Roth
Published on 2010-04-12T10:51:55Z Indexed on 2010/04/12 10:53 UTC
Read the original article Hit count: 234

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about db2

Related posts about sql