table of number index by varchar2(100)
来源:互联网 发布:迅雷玩客云 淘宝众筹 编辑:程序博客网 时间:2024/06/02 05:39
--字符串序列要这样
declare
type t istable of number(3) indexby varchar2(3);
hash_t t;
l_row varchar2(3);
begin
hash_t('a') := 10;
hash_t('b') := 20;
l_row :=hash_t.first;
while(l_rowisnot null) loop
dbms_output.put_line(hash_t(l_row));
l_row:=hash_t.next(l_row);
endloop;
end;
--数字序列可以这样
declare
type t istable of number(3) indexby pls_integer;
hash_t t;
l_row varchar2(3);
begin
hash_t(1) := 10;
hash_t(2) := 20;
fori inhash_t.first.. hash_t.lastloop
dbms_output.put_line(hash_t(i));
endloop;
end;
declare
type t istable of number(3) indexby varchar2(3);
hash_t t;
l_row varchar2(3);
begin
hash_t('a') := 10;
hash_t('b') := 20;
l_row :=hash_t.first;
while(l_rowisnot null) loop
dbms_output.put_line(hash_t(l_row));
l_row:=hash_t.next(l_row);
endloop;
end;
--数字序列可以这样
declare
type t istable of number(3) indexby pls_integer;
hash_t t;
l_row varchar2(3);
begin
hash_t(1) := 10;
hash_t(2) := 20;
fori inhash_t.first.. hash_t.lastloop
dbms_output.put_line(hash_t(i));
endloop;
end;
语句:type numbers is table of number index by binary_integer;其作用是,加了”index by binary_integer ”后,numbers类型的下标就是自增长,
可以自动根据下标找到对应的值。numbers类型在插入元素时,不需要初始化,不需要每次extend增加一个空间。
而如果没有这句话“index by binary_integer”,那就得要显示对初始化,且每插入一个元素到numbers类型的table中时,都需要先extend.
没加“index by binary_integer”时:
declare
type numbers is table of number;
m numbers := numbers();
begin
m.extend;
m(1) := 2;
m.extend;
m(2) := 3;
for i in1 .. m.count loop
dbms_output.put_line(m(i));
end loop;
end;
输出:2,3
而如果加了“index by binary_integer”,代码如下写就可以达到上面的效果
declare
type numbers is table of number index by binary_integer;
m numbers;
begin
m(1) := 2;
m(2) := 3;
for i in 1..m.count loop
dbms_output.put_line(m(i));
end loop;
end;
可以自动根据下标找到对应的值。numbers类型在插入元素时,不需要初始化,不需要每次extend增加一个空间。
而如果没有这句话“index by binary_integer”,那就得要显示对初始化,且每插入一个元素到numbers类型的table中时,都需要先extend.
没加“index by binary_integer”时:
declare
type numbers is table of number;
m numbers := numbers();
begin
m.extend;
m(1) := 2;
m.extend;
m(2) := 3;
for i in1 .. m.count loop
dbms_output.put_line(m(i));
end loop;
end;
输出:2,3
而如果加了“index by binary_integer”,代码如下写就可以达到上面的效果
declare
type numbers is table of number index by binary_integer;
m numbers;
begin
m(1) := 2;
m(2) := 3;
for i in 1..m.count loop
dbms_output.put_line(m(i));
end loop;
end;
阅读全文
0 0
- table of number index by varchar2(100)
- 学习TYPE IS TABLE OF VARCHAR2 INDEX BY VARCHAR
- type … is table of number index by binary_integer
- 遍历关联数组 index by varchar2
- table access by index rowid
- table access by index rowid
- oracle常用的复合数据类型 : BULK COLLECT和is table of table_name%rowtype index by
- INDEX BY TABLE 记录索引表
- Oracle TABLE ACCESS BY INDEX ROWID 说明
- oracle index-by table的遍历
- PLSQL collection 示例 之 index-by table
- PLSQL collection 示例 之 index-by table
- Caused by: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0
- Caused by: java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0
- Caused by: java.sql.SQLException: Parameter index out of range (3 > number of parameters, which is 2
- Caused by: java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1
- 实战BULK COLLECT(成批聚合类型)和数组集合type 类型is table of 表%rowtype index by
- 实战BULK COLLECT(成批聚合类型)和数组集合type类型is table of 表%rowtype index by binary_integer
- 顺序表应用6:有序顺序表查询
- 简单购物车
- ThinkPhp3.2无法加载控制器
- h5使用audio标签录音
- java 关于读取excel表内的日期时间
- table of number index by varchar2(100)
- 网易云深度学习第一课第三周编程作业
- 搭建Zookeeper环境
- VB
- opencv各种滤波器的用法
- AngularJS中【Error: [$rootScope:inprog]】的解决办法
- javan面向对象编程的概念
- C++开发者都应该使用的10个C++11特性
- 职场上这些操作都不会?3个excel操作技巧帮你轻松解决问题