原来这样,下面的代码如果不加“index by binary_integer”,就要用 table1 tabletype1:=tabletype1(); table.extend;Declare type tabletype1 is table of varchar2(9) index by binary_integer; table1 tabletype1; begin table1(1):='成都市'; table1(2):='北京市'; table1(3):='青岛市'; dbms_output.put_line('总记录数:'||to_char(table1.count)); dbms_output.put_line('第一条记录:'||table1.first); dbms_output.put_line('最后条记录:'||table1.last); dbms_output.put_line('第二条的前一条记录:'||table1.prior(2)); dbms_output.put_line('第二条的后一条记录:'||table1.next(2)); end;
8楼说得对,不加的话就要变成: declare type tabletype1 is table of varchar2(9) index by binary_integer; table1 tabletype1=tabletype1(); begin n.extend; table1(1):='成都市'; n.extend; table1(2):='北京市'; end; 也就是说,加了index by binary_integer;tabletype1 类型的下标就是自增长的,tabletype1 类型在插入元素时,不需要初始化,不需要每次extend增加一个空间。------------------ 广告:南通吃喜酒婚庆网
标号的数组。
table.extend;Declare
type tabletype1 is table of varchar2(9) index by binary_integer;
table1 tabletype1;
begin
table1(1):='成都市';
table1(2):='北京市';
table1(3):='青岛市';
dbms_output.put_line('总记录数:'||to_char(table1.count));
dbms_output.put_line('第一条记录:'||table1.first);
dbms_output.put_line('最后条记录:'||table1.last);
dbms_output.put_line('第二条的前一条记录:'||table1.prior(2));
dbms_output.put_line('第二条的后一条记录:'||table1.next(2));
end;
declare
type tabletype1 is table of varchar2(9) index by binary_integer;
table1 tabletype1=tabletype1();
begin
n.extend;
table1(1):='成都市';
n.extend;
table1(2):='北京市';
end;
也就是说,加了index by binary_integer;tabletype1 类型的下标就是自增长的,tabletype1 类型在插入元素时,不需要初始化,不需要每次extend增加一个空间。------------------
广告:南通吃喜酒婚庆网