0

我正在尝试在存储过程中的分析视图上按维度进行吐痰,并且我想传递我将动态应用聚合函数的度量。所以我做了以下事情:

 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 不推荐它。

那么如何动态传递聚合度量呢?

4

1 回答 1

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;

当然,这只适用于最新版本。您正在运行哪个版本?

于 2013-10-29T17:47:29.337 回答