1
當我在包中定義PLSQL無效的數據類型,即使在鑄造後,爲什麼
SQL> select cast(csv_convert.to_text('ABC,ACD,DE') as t_tbl_of_text) from dual;
select cast(csv_convert.to_text('ABC,ACD,DE') as t_tbl_of_text) from dual
*
**ERROR at line 1:
ORA-00902: invalid datatype**
create or replace package csv_convert is
type t_tbl_of_text is table of varchar2(32767);
function to_text(p_str in varchar2)
return t_tbl_of_text;
end csv_convert;
/
Package created.
create or replace package body csv_convert as
function to_text(p_str in varchar2) return t_tbl_of_text is
l_data t_tbl_of_text := t_tbl_of_text();
l_str varchar2(32767) default p_str || ',';
l_n number;
begin
loop
l_n := instr(l_str, ',');
exit when (nvl(l_n,0) = 0);
l_data.extend;
l_data(l_data.count) := trim(substr(l_str,1,l_n-1));
l_str := substr(l_str, l_n+1);
end loop;
return l_data;
end to_text;
end csv_convert;
/