我一直在sap hana语法中再次敲打我的头。我一直在寻找一种方法来编写函数或过程,并在select语句中调用函数或过程来评估表中的列,并根据if函数改变列。在sap hana的select语句中调用过程或函数
我已经创建了大部分脚本,但替换函数未按预期工作。我不太熟悉sap hana,所以任何帮助将不胜感激。谢谢。
有人也可以让我知道我该怎么称呼这个程序,因为这在sap hana中似乎有点复杂。我使用花属10
create procedure update_str
language sqlscript
as
ip_str varchar:= '21222212';
temp_str varchar(100) := ip_str || ',';
pos integer :=1;
begin
while(length(:temp_str) > 0) do
if substr(temp_str,1,1) = '1' and substr (temp_str,2,1) = '2' then
update temp_str := replace(temp_str,'12','12,');
pos := :pos + 1;
elseif substr(temp_str,1,1) = '2' and substr (temp_str,2,1) = '1' then
update temp_str := replace(temp_str,'21','2,1');
pos := :pos + 1;
elseif substr(temp_str,1,1) = '2' and substr (temp_str,2,1) = '2' then
update temp_str := replace(temp_str,'22','2,2');
pos := :pos + 1;
else;
end if;
end if;
end if;
end while;
end;
我想基本上使用SELECT语句并输出结果如下什么,我想实现
例如运行函数或过程
ID |字符串已更新| 12212 | |从函数或过程
1 temp_str 12,2,12
2 | 21221 | 2,12,2,1
3 | 12212 | 12,2,12
感谢Lars为您提供这方面的帮助。我能够关注。非常感谢。 – MRUNIVERSE