储存过程中的数组与可变数组

来源:互联网 发布:淘宝新开店铺没有关注 编辑:程序博客网 时间:2024/06/17 12:41

create or replace procedure pro_test
(
 emp_cv in out cy_types.empinfotype
)
as
e_count exception;
v_count number(9);
type study is table of varchar2(20) index by binary_integer;
v_study study;

/*可变数组使用*/
type dates is varray(7) of varchar2(10);
v_dates dates:=dates('monday','tuesday','wednesday');
begin

open emp_cv for select * from cyg;
select count(*) into v_count from cyg;
if v_count>1 then
raise e_count;
end if;
exception
when e_count then
dbms_output.put_line('current count is:'||v_count);
for v_count in 1..5 loop
v_study(v_count):=v_count*100;
end loop;
for v_count in 1..5 loop
dbms_output.put_line(v_study(v_count));
end loop;

 


/*可变数组的用法*/
dbms_output.put_line(v_dates(1));
dbms_output.put_line(v_dates(2));
dbms_output.put_line(v_dates(3));
end;

原创粉丝点击