求把oracle自定义函数转GBASE自定义函数

create or replace type ty_str_split is table of varchar2 (4000)

create or replace function fun_split (p_str in varchar2, p_delimiter in varchar2)
return ty_str_split
is
j int := 0;
i int := 0;
getLen int :=0;
len int := 0;
len1 int := 0;
str varchar2 (4000);
str_split ty_str_split := ty_str_split ();
v_isFound number:=0;
begin
if p_delimiter is not null then
select instr(p_str,p_delimiter) into v_isFound from dual;
if v_isFound=0 then--没找到
str_split.extend;
str_split (str_split.count) := p_str;
else
len := length (p_str);
len1 := length (p_delimiter);
while j <= len
loop
i:=i+1;
j := instr (p_str, p_delimiter,i);
getLen:=j-i;

            if j = 0  then
                str := substr (p_str, i);
                str_split.extend;
                str_split (str_split.count) := str;
                exit;
            else
                str := substr (p_str, i, getLen);
                str_split.extend;
                str_split (str_split.count) := str;
                i := j-1 + len1;
                end if;
        end loop;
    end if ;
else
    str_split.extend;
    str_split (str_split.count) := p_str;
end if ;
return str_split;

end fun_split;

没有币,谢谢了

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问