문제

I need to alter a macro the way that a parameter can be passed to control the max size of the result set.

My idea was this SQL:

REPLACE MACRO myMacro
( maxRows INTEGER DEFAULT 100 )
AS
(
    SELECT TOP :maxRows
    FROM myTable;
);

But all I get is the message:

[SQLState 42000] Syntax error,Expected something like an Integer or decimal number between 'top' and ':'.

It's not possible for me to do this in any other way than a macro.

How can I do that?

도움이 되었습니까?

해결책

I found a way to do this:

REPLACE MACRO myMacro
( maxRows INTEGER DEFAULT 100 )
AS
(
    SELECT 
        ROW_NUMBER() OVER (ORDER BY myColumn) AS RowNo, 
        myColumn
    FROM myTable
    WHERE RowNo <= :maxRows;
);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top