我正在尝试在存储过程中的分析视图上按维度进行吐痰,并且我想传递我将动态应用聚合函数的度量。所以我做了以下事情:
create procedure procHO (in currentMeasure varchar(60))
language sqlscript as
begin
data_tab = select MONTH_NAME as ID, sum(:currentMeasure) from
_SYS_BIC."schema/analyticView" GROUP BY MONTH_NAME;
end;
然后我这样调用程序:
call procHO("MARGIN");
但我收到一条错误消息:
inconsistent datatype: only numeric type is available for aggregation function: line 5 col 38 (at pos 124) Could not execute 'call procHO("MARGIN")'
我也尝试使用 CE_ 函数来做到这一点,这就是我所做的:
create procedure procHO1(in currentMeasure varchar(60))
language sqlscript as
begin
out1 = CE_OLAP_VIEW("schema/analyticView", ["MONTH_NAME",
SUM(:currentMeasure)]);
end;
我这样称呼这个程序:
call procHO1("MARGIN");
但是,我仍然收到一条错误消息:
feature not supported: line 5 col 70 (at pos 157)
Could not execute 'call procHO1("MARGIN")'
顺便说一句,作为一种解决方法,可以创建一个动态 SQL 查询来解决这个问题,这里有一个例子: create procedure procHO2(in currentMeasure varchar(60)) language sqlscript as begin
exec 'select MONTH_NAME AS ID, sum('||:currentMeasure||') as SUM_MEASURE from
_SYS_BIC."schema/analyticView" GROUP BY MONTH_NAME';
end;
我这样称呼它
call procHO2('MARGIN');
但我不想动态创建 SQL 查询,因为 SAP 不推荐它。
那么如何动态传递聚合度量呢?