Oracle中数组类型的几种用法
来源:互联网 发布:ntfs for mac安装包 编辑:程序博客网 时间:2024/05/29 07:41
这里只讨论简单讨论一下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;
上面的用法中自己先定义了一个类型,然后又定义了该类型的数组。
参考:http://fxz-2008.iteye.com/blog/469766
- Oracle中数组类型的几种用法
- java中数组复制的几种常见用法
- 几种字符串数组函数的用法
- 数组复制的几种常见用法
- 删除数组的常见几种用法
- Oracle的数组类型
- java中byte数组与int类型的转换的几种方式
- Oracle 自定义TYPE 的几种用法
- Oracle 自定义TYPE 的几种用法
- Oracle PLSQL 几种游标的用法
- Oracle中常用的几种数据类型
- ios 中数组,字典 集合类型的几种常用枚举方法
- ios 中数组,字典 集合类型的几种常用枚举方法
- C++中传递数组参数的几种用法和注意点
- c#中数组,类型转换,using语句的其他用法
- oracle中Blob和Clob类型的区别与用法
- ORACLE中时间类型的转换cast用法
- javascript——检测数组类型的几种方法
- 嵌入式Linux内核安装
- Myeclipse 中vss状态不显示的问题解决
- Siebel Error:CmdData:MakeCallToSROwner has incorrect syntax.
- 感谢教我C语言的秋香姐
- 非阻塞套接字
- Oracle中数组类型的几种用法
- Bad version number in .class file问题处理
- UIPopoverController的使用
- 学习flex的好网站,还不错
- Extjs中将数据导出为Excel表格
- 自己意识到的 UI 新趋势
- 浅谈 static
- jquery对select option的操作(收集)
- 敏捷开发