DB2:不允许参数化:'fetch first< X>行只' [英] DB2: Won't allow parameterize: 'fetch first <X> rows only'
问题描述
尽管在 Oracle DB中,它允许通过添加查询来参数化查询可以获取的行数:
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
我不能在 DB2 中运行的acuivalent查询添加类似的条件:
允许添加: / p>
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)
(:1 == @MaximumRecords)
有人知道解决方案/解决这个问题吗?
Is someone aware of a solution/work-around to this problem?
推荐答案
我想我发现解。我刚刚运行这个查询,并给出了一个默认值为@MaximnumRecords
的工具,并且DB2不允许执行:
仅提取0行 strong>在任何情况下 - 这是问题。
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.
这篇关于DB2:不允许参数化:'fetch first< X>行只'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!