oracle index-by table的遍历
2013-08-07 13:44
357 查看
Oracle的数据集合类型,分三种:
Varray:固定长度(其他方法可扩展),连续的数组。对应其他程序中的数组。
Nested table:长度不固定,不连续。对应其他程序中的set,list等。
Associative Arrays(Known as index-by table):有索引的集合。对应其他程序中的hashMap。
前面的两种集合类型,遍历都比较简单,有很多种方法来遍历。最后一种,比较困惑人,看pl/sql的参考文档,更困惑人。问了几个同事,也都表示不知道。最后,摸索出来了,记在这里,备忘,也希望帮助更多人.....
Varray:固定长度(其他方法可扩展),连续的数组。对应其他程序中的数组。
Nested table:长度不固定,不连续。对应其他程序中的set,list等。
Associative Arrays(Known as index-by table):有索引的集合。对应其他程序中的hashMap。
前面的两种集合类型,遍历都比较简单,有很多种方法来遍历。最后一种,比较困惑人,看pl/sql的参考文档,更困惑人。问了几个同事,也都表示不知道。最后,摸索出来了,记在这里,备忘,也希望帮助更多人.....
declare type tab_result is table of varchar2(20) index by varchar2(20); vt_result tab_result; which varchar2(20); begin vt_result('a'):='asd'; vt_result('u'):='lkj'; vt_result('e'):='hgj'; vt_result('i'):='uey'; --如何遍历? which:=vt_result.first; loop dbms_output.put_line(which||'--->'); dbms_output.put_line(vt_result(which)); which:=vt_result.next(which); exit when which is null; end loop; end;
相关文章推荐
- Flex 遍历 DataGrid【原创】
- Python os.path.walk遍历文件,搜索文件里面的内容
- 二叉树的遍历
- PHP函数遍历数组
- 如何遍历memcache
- C foreach 需要遍历多个list的问题
- for循环—V字形、逢10换行、遍历2维数组、嵌套元素、点击生成一组新闻
- 数据结构----图的遍历(DFS)
- 《编程之美》:分层遍历二叉树
- struts2的iterator标签遍历list数组时候,对date标签的使用
- java 中遍历Map的几种方法
- Atitit.遍历图像像素点rgb java attilax总结
- 遍历Map 集合的四种方法
- Gym 101149I It's the Police 图+简单遍历
- 面试题24. 二叉搜索树的后序遍历序列
- 遍历Map的四种方法
- Java中Map的遍历方法
- JAVA 遍历Map
- c++ 遍历文件夹所有文件
- ng-repeat 循环遍历数组