gpt4 book ai didi

sql - HANA:拆分字符串?

转载 作者:行者123 更新时间:2023-12-01 23:03:59 27 4
gpt4 key购买 nike

有没有办法在 HANA 中拆分字符串?

类似于 SQL Server 中的等效项:SELECT * FROM dbo.fnSplitString('valueA,valueB', ',')

最佳答案

尝试这个,

Refer Here

CREATE PROCEDURE SPLIT_TEST(TEXT nvarchar(100))
AS
BEGIN
declare _items nvarchar(100) ARRAY;
declare _text nvarchar(100);
declare _index integer;
_text := :TEXT;
_index := 1;

WHILE LOCATE(:_text,',') > 0 DO
_items[:_index] := SUBSTR_BEFORE(:_text,',');
_text := SUBSTR_AFTER(:_text,',');
_index := :_index + 1;
END WHILE;
_items[:_index] := :_text;

rst = UNNEST(:_items) AS ("items");
SELECT * FROM :rst;
END;

CALL SPLIT_TEST('A,B,C,E,F')

关于sql - HANA:拆分字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27709088/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com