Erp100论坛's Archiver

xiangzhao 发表于 2008-8-11 20:55

对集合的整理资料

集合
index_by表
嵌套表(可以存储在数据库中)  
可变数组


index by表:
定义方式:type tabletype is table of type index by binary_interget
特点:关键字可以是binary_interget的任意值,不需要初始化
例子:   
TYPE StudentTab IS TABLE OF students%ROWTYPE INDEX BY BINARY_INTEGER;
v_Students(1).first_name := 'Larry';


嵌套表:
定义方式:type tabletype is table of type [not null]
特点:关键字不能是负值,必须用有序的关键字创建,可以存储在表中,使用前必须先初始化
例子:
  TYPE NumbersTab IS TABLE OF NUMBER;
  -- Create a table with one element.
  v_Tab1 NumbersTab := NumbersTab(-1);
备注:
v_Tab1 NumbersTab ;
v_Tab1 := NumbersTab(-1);
等同于
v_Tab1 NumbersTab := NumbersTab(-1);

可变数组:
定义方式:type type_name is {varray | varying varray} (max_size) of element_type[not null]
特点:跟嵌套表相似,不过他有最大值限制
例子:
  TYPE Strings IS VARRAY(5) OF VARCHAR2(10);
  v_List Strings := Strings('One', 'Two', 'Three');

页: [1]

Powered by Discuz! Archiver 7.0.0  © 2001-2007 Comsenz Inc.