--Oracle 示例函数
CREATE OR REPLACE TYPE "T_RET_TABLE" IS TABLE OF VARCHAR2 (4000)
/
CREATE OR REPLACE FUNCTION "ROW_SPLIT" (var_str in string, var_split In String)
return t_ret_table
PIPELINED as
var_tmp clob;
var_element clob;
n_length Number := length(var_split);
begin
var_tmp := var_str;
while instr(var_tmp, var_split) > 0 loop
var_element := substr(var_tmp, 1, instr(var_tmp, var_split) - 1);
var_tmp := substr(var_tmp,
instr(var_tmp, var_split) + n_length,
length(var_tmp));
pipe row(var_element);
end loop;
pipe row(var_tmp);
return;
end row_split;
/
--YashanDB 改写参考
CREATE OR REPLACE TYPE "T_RET_TABLE" IS TABLE OF VARCHAR2 (4000)
/
CREATE OR REPLACE FUNCTION "ROW_SPLIT" (var_str in varchar, var_split In varchar)
return t_ret_table IS
var_trt t_ret_table;
var_tmp varchar2(8000);
var_element varchar2(8000);
n_length Number := length(var_split);
begin
var_trt := t_ret_table();
var_tmp := var_str;
while instr(var_tmp, var_split) > 0 loop
var_element := substr(var_tmp, 1, instr(var_tmp, var_split) - 1);
var_tmp := substr(var_tmp,
instr(var_tmp, var_split) + n_length,
length(var_tmp));
var_trt.extend(1);
var_trt(var_trt.COUNT) := var_element;
end loop;
var_trt.extend(1);
var_trt(var_trt.COUNT) := var_tmp;
return var_trt;
end row_split;
/
评论