1
我是oracle中的新成员。我有一个关于TSQL的函数,我需要将它翻译成pl/sql。 函数用一些规则分隔传入的字符串。所以我试试这个:函数返回表。 pl/sql
create or replace
FUNCTION FN_PROPSTOTABLE(stValues in varchar2) RETURN POPSTBL AS
tbl PROPSTBL;
s varchar2(8000);
ind varchar2(100);
val varchar2(100);
p int;
tmp varchar2(8000);
BEGIN
tmp:=stValues;
while LENGTH(tmp)>0
loop
p:=instr(tmp, ':');
IF p=0 THEN
p:=LENGTH(tmp);
END IF;
s:=SUBSTR(tmp, 0, p);
tmp:=SUBSTR(tmp, LENGTH(s)+1);
s:=REPLACE(s, ':', '');
ind:=substr(s,0, instr(s, '|')-1);
val:=substr(s,instr(s, '|')+1);
select b bulk collect into tbl
from (select props(ind, val) b from dual);
end loop;
RETURN tbl;
END FN_PROPSTOTABLE;
这很好,但它只返回最后一个子字符串。请帮帮我。
'POPSTBL'的定义是什么? (发布'create type ...'声明) –
@a_horse_with_no_name:我要做出有根据的猜测并说:'CREATE TYPE PROPSTBL AS PROPS' :) –