我试图通过维度对存储过程中的分析视图进行吐出,并且我希望传递我将动态应用聚合函数的度量。所以我做了以下事情:
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查询,这是一个例子:
创建过程procHO2(在currentMeasure varchar(60)中)
语言sqlscript为
开始
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不推荐它。
那么如何动态传递聚合度量呢?
答案 0 :(得分:1)
这是文档中的示例代码:
CREATE PROCEDURE my_proc_caller (IN in_client INT, IN in_currency INT, OUT outtab mytab_t) LANGUAGE SQLSCRIPT
BEGIN
outtab = SELECT * FROM CALC_VIEW (PLACEHOLDER."$$client$$" => :in_client , PLACEHOLDER."$$currency$$" => :in_currency );
END;
当然这仅适用于最新版本。您正在运行哪个版本?