create or replace type type_table is table of varchar2(100);
create or replace function returnLanguage
(
s_language varchar2
)
return table_strs
is
table_strs type_table;
begin
--最多出現倆國語言
if instr(s_language, ',', 1, 2) > 0 then
dbms_output.put_line('抛出異常');
--如果存在倆國語言
elsif instr(s_language, ',',1,1) > 0 then
table_strs(0) := substr(s_language, 0, instr(s_language, ',',1,1) - 1);
table_strs(1) := substr(s_language, instr(s_language, ',',1,1) + 1, length(s_language));
dbms_output.put_line(table_strs(0));
dbms_output.put_line(table_strs(1));
--如果隻存在一國語言
elsif instr(s_language, ',',1,1) = 0 then
table_strs(0) := s_language;
dbms_output.put_line(table_strs(0));
end if;
end;