Oracle中数组类型的几种用法
2011-07-13 16:36
781 查看
这里只讨论简单讨论一下Oracle中嵌套表数组的用法:
declare
type my_first_type is table of varchar2(20) index by binary_integer;
l_test_type my_first_type;
l_index number ;
begin
for t_id_no in (select * from ls_appl) loop
l_test_type(t_id_no.ls_appl_seq):=t_id_no.appl_loan_no;
end loop;
l_index := l_test_type.first;
loop
exit when l_index is null ;
dbms_output.put_line(l_index ||' : ' ||l_test_type(l_index));
l_index := l_test_type.next(l_index);
end loop;
end;
上面的用法中声明一个varchar2类型的数组,其实of后面的只是一个数据类型。
我们用ls_appl表中的一个字段去填充它。
declare
type my_type is table of loan%rowtype index by binary_integer;
l_my_type my_type;
begin
select * bulk collect into l_my_type from loan;
for l_c in 1 .. l_my_type.count loop
dbms_output.put_line(l_my_type(l_c).loan_no ||' : '||l_my_type(l_c).ctif_id_no);
end loop;
end;
上面的用法有些时候可以用于替代cursor。
declare
type my_record is record(hh number(15),nn varchar2(20));
l_my_record my_record;
type my_type is table of l_my_record%type index by binary_integer;
l_my_type my_type;
begin
select l.ls_appl_seq,l.appl_no bulk collect into l_my_type from ls_appl l;
for i in 1 .. l_my_type.count loop
dbms_output.put_line(l_my_type(i).hh || ' : ' ||l_my_type(i).nn);
end loop;
end;
上面的用法中自己先定义了一个类型,然后又定义了该类型的数组。
参考:/article/4169885.html
declare
type my_first_type is table of varchar2(20) index by binary_integer;
l_test_type my_first_type;
l_index number ;
begin
for t_id_no in (select * from ls_appl) loop
l_test_type(t_id_no.ls_appl_seq):=t_id_no.appl_loan_no;
end loop;
l_index := l_test_type.first;
loop
exit when l_index is null ;
dbms_output.put_line(l_index ||' : ' ||l_test_type(l_index));
l_index := l_test_type.next(l_index);
end loop;
end;
上面的用法中声明一个varchar2类型的数组,其实of后面的只是一个数据类型。
我们用ls_appl表中的一个字段去填充它。
declare
type my_type is table of loan%rowtype index by binary_integer;
l_my_type my_type;
begin
select * bulk collect into l_my_type from loan;
for l_c in 1 .. l_my_type.count loop
dbms_output.put_line(l_my_type(l_c).loan_no ||' : '||l_my_type(l_c).ctif_id_no);
end loop;
end;
上面的用法有些时候可以用于替代cursor。
declare
type my_record is record(hh number(15),nn varchar2(20));
l_my_record my_record;
type my_type is table of l_my_record%type index by binary_integer;
l_my_type my_type;
begin
select l.ls_appl_seq,l.appl_no bulk collect into l_my_type from ls_appl l;
for i in 1 .. l_my_type.count loop
dbms_output.put_line(l_my_type(i).hh || ' : ' ||l_my_type(i).nn);
end loop;
end;
上面的用法中自己先定义了一个类型,然后又定义了该类型的数组。
参考:/article/4169885.html
相关文章推荐
- Android MimeType的用法和几种类型
- jdbc批量(bulk )insert———oracle数组类型与forall的应用
- oracle常用的复合数据类型 : BULK COLLECT(成批聚合类型)和数组集合type类型is table of 表%rowtype index by binary_integer
- Oracle中表的几种类型
- Android MimeType的用法和几种类型
- Oracle三种集合数据类型(索引表,嵌套表,VARRAY 数组)的比较-PLSQL—之三
- 详解Oracle临时表的几种用法及意义
- 数组的几种不常见用法
- java数组复制的几种常见用法
- Oracle存储过程传入类似java中list、数组类型的参数并使用
- ios 中数组,字典 集合类型的几种常用枚举方法
- Oracle 自定义TYPE 的几种用法(转)
- jdbc批量(bulk )insert———oracle数组类型与forall的应用
- Oracle 自定义TYPE 的几种用法
- 详解Oracle临时表的几种用法及意义
- 详解Oracle临时表的几种用法及意义
- 几种字符串数组函数的用法
- Oracle number类型的语法和用法
- Oracle 10g复合数据类型pl/sql集合学习六——索引表、嵌套表、变长数组
- oracle常用的复合数据类型 : BULK COLLECT(成批聚合类型)和数组集合type类型is table of 表%rowtype index by binary_integer