create or replace function JC_TESTFUC(sname in varchar2) return nvarchar2 is
type t_list is table of abc%rowtype index by binary_integer;
nstr varchar2(3000);
i integer:=0;
s_date number;
e_date number;
temp_l number;
t_infos t_list;
begin
if sname = 'case1' then
dbms_output.put_line('I am case1');
elsif sname = 'case2' then
dbms_output.put_line('I am case2');
elsif sname = 'loop' then
loop
insert into aa(sname) values(i);
exit when i=10;
i:=i+1;
end loop;
elsif sname='for' then
for i in 1..10 loop
insert into aa(sname) values('for insert '||i);
end loop;
elsif sname='while' then
while i<10 loop
insert into aa(sname) values('while insert '||i);
i:=i+1;
end loop;
elsif sname = 'forall' then
-- 此种方法优化了PL/SQL引擎,效率最快,可作为批量导入的考虑
-- 不过需要使用 bulk collect 才可以,还有待研究
select * bulk collect into t_infos from abc where rownum<10000;
s_date :=dbms_utility.get_time;
dbms_output.put_line('s_date '||s_date);
forall i in 1..t_infos.count
insert into aa(sname) values(t_infos(i).tname);
e_date := dbms_utility.get_time;
temp_l := e_date - s_date;
dbms_output.put_line(temp_l);
end if;
return nstr;
end JC_TESTFUC;