Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要更改宏,以便可以传递参数来控制结果集的最大大小。
我的想法是这个 SQL:
REPLACE MACRO myMacro ( maxRows INTEGER DEFAULT 100 ) AS ( SELECT TOP :maxRows FROM myTable; );
但我得到的只是信息:
[SQLState 42000] 语法错误,应为“top”和“:”之间的整数或十进制数。
除了宏之外,我不可能以任何其他方式做到这一点。
我怎样才能做到这一点?
我找到了一种方法来做到这一点:
REPLACE MACRO myMacro ( maxRows INTEGER DEFAULT 100 ) AS ( SELECT ROW_NUMBER() OVER (ORDER BY myColumn) AS RowNo, myColumn FROM myTable WHERE RowNo <= :maxRows; );