您好我是SAP HANA的新手,我有这个T-SQL代码:
`if(@IsBes='E')begin
if((select top 1 U_bBesYontem from OHEM where empID=@EmpId)='O') begin
set @Bes=@Brut*(select top 1 U_bBesOran from OHEM where empID=@EmpId)/100
end
if((select top 1 U_bBesYontem from OHEM where empID=@EmpId)='T') begin
set @Bes=(select top 1 U_bBesTutar from OHEM where empID=@EmpId)
end
end`
我正在为SAP HANA尝试此代码
IF (:IsBes = 'E') THEN
IF ((SELECT TOP 1 “U_bBesYontem"
FROM
OHEM
WHERE
"empID" = :EmpId) = 'O')
THEN
Bes := :Brut * (SELECT TOP 1 "U_bBesOran"
FROM OHEM
WHERE
"empID" = :EmpId) / 100;
END IF;
IF ((SELECT TOP 1 "U_bBesYontem"
FROM OHEM
WHERE "empID" = :EmpId) = 'T') THEN
SELECT (SELECT TOP 1 "U_bBesTutar"
FROM OHEM
WHERE "empID" = :EmpId) INTO Bes
FROM DUMMY;
END IF;
END IF;
尝试了很多代码变体,但我总是得到这个错误:
SAP DBTech JDBC: [7]: feature not supported:
Sub-query is not supported in a nested procedure call:
line 47 col 28 (at pos 2273)
我很困惑所以有人可以给出任何建议吗?
答案 0 :(得分:1)
Merhaba,
您能否在测试数据库上执行以下SQLScript
do
begin
declare lv_EmpId int := 1;
declare lv_IsBes char(1) := 'E';
declare lv_Bes decimal(10,2);
declare lv_Brut decimal(10,2) := 100;
declare lv_U_bBesYontem nvarchar(100);
declare lv_U_bBesOran int;
declare lv_U_bBesTutar int;
select top 1
U_bBesYontem, U_bBesOran, U_bBesTutar
into
"LV_U_BBESYONTEM", "LV_U_BBESORAN", "LV_U_BBESTUTAR"
from OHEM where EmpId = lv_EmpId;
if (:lv_IsBes = 'E') then
if(:lv_U_bBesYontem = 'O') then
lv_Bes = ( :lv_Brut * :lv_U_bBesOran ) /100;
else
if (:lv_U_bBesYontem = 'T') then
lv_Bes = :lv_U_bBesTutar;
end if;
end if;
end if;
select :lv_Bes as "BES" from dummy;
end;
我使用了以下示例数据,它似乎工作得很好,请根据您的表和字段名称修改脚本等。
CREATE Column TABLE OHEM (
empID int,
U_bBesYontem varchar(10),
U_bBesOran int,
U_bBesTutar int
);
insert into OHEM select 1, 'O',5,1000 from dummy;
insert into OHEM select 2, 'O',10,500 from dummy;
insert into OHEM select 1, 'T',5,1000 from dummy;
insert into OHEM select 2, 'T',10,500 from dummy;
您可以在给定样本文档的SQLScript上引用变量声明,值赋值,IF子句等。