--取出集合;长度
declare
type list_nested is table of varchar2(50) not null;
v_all list_nested := list_nested('a','b','c','d','c','d');
begin
dbms_output.put_line('list leng :' || cardinality(v_all));
end;
/ --从集合中取出取消重复的元素
declare
type list_nested is table of varchar2(50) not null;
v_all list_nested := list_nested('a','b','c','d','c','d');
begin
dbms_output.put_line('list leng :' || cardinality((set(v_all))));
end;
/ --判断集合是否为空
declare
type list_nested is table of varchar2(50) not null;
v_allA list_nested := list_nested('shanghai','beijing','changan');
v_allB list_nested := list_nested('shanghai');
begin
if v_allA is not empty then
dbms_output.put_line('v_allA not null!');
end if;
if v_allB is empty then
dbms_output.put_line('v_allB is null!');
else
dbms_output.put_line('v_allB not null!!');
end if;
end;
/ --判断字符是否存在
declare
type list_nested is table of varchar2(50) not null;
v_allA list_nested := list_nested('shanghai','beijing','changan');
v_allB list_nested := list_nested('shanghai');
v_str varchar2(20) := 'shanghai';
begin
if v_str member of v_allA then
dbms_output.put_line('shanghai value is exists');
end if;
end;
/( --使用for循环遍历集合的每一个元素; 取出list中交集
declare
type list_nested is table of varchar2(50) not null;
v_allA list_nested := list_nested('shanghai','beijing','hunan');
v_allB list_nested := list_nested('Java','beijing','tianjing');
v_newlist list_nested ;
BEGIN
v_newlist := v_allA multiset except v_allB;
for x in 1 .. v_newlist.count loop
dbms_output.put_line(v_newlist(x));
end loop;
end;
/ --使用for循环遍历集合的每一个元素; 取出集合中所有的元素
declare
type list_nested is table of varchar2(50) not null;
v_allA list_nested := list_nested('shanghai','beijing','hunan');
v_allB list_nested := list_nested('Java','beijing','tianjing');
v_newlist list_nested ;
BEGIN
v_newlist := v_allA multiset union v_allB;
for x in 1 .. v_newlist.count loop
dbms_output.put_line(v_newlist(x));
end loop;
end;
/ 判断集合是否为集合
declare
type list_nested is table of varchar2(50) not null;
v_allA list_nested := list_nested('shanghai','beijing','Java');
begin
if v_allA is A set then
dbms_output.put_line('v_allA is list');
end if;
end;
/ declare
type list_nested is table of varchar2(50) not null;
v_allA varchar2(20) := 'a';
begin
if v_allA is A set then
dbms_output.put_line('v_allA is list');
end if;
end;
/ --判断B是否为A的子集合
declare
type list_nested is table of varchar2(50) not null;
v_allA list_nested := list_nested('shanghai','beijing','hunan','Java');
v_allB list_nested := list_nested('Java','beijing');
BEGIN
if v_allB submultiset v_allA then
dbms_output.put_line('v_allB is v_allA submultiset');
end if;
end;
/
--集合的异常处理;
--理解集合异常的缠身及处理操作; 所有异常捕获都能够使用others进行捕获; DECLARE
type list_varray is varray(8) of varchar2(50);
v_info list_varray; --此时的集合变量没有初始化
BEGIN
v_info(0) := 10; --此集合未初始化,所以会存在错误,
exception
when collection_is_null then
dbms_output.put_line('The error collection is not initialized');
END;
/ DECLARE
type list_varray is varray(8) of varchar2(50);
v_info list_varray := list_varray('shanghai','changan','facebook');
BEGIN
dbms_output.put_line(v_info(5));
exception
when subscript_beyond_count then
dbms_output.put_line('索引值超过定义的元素个数!!');
end;
/ DECLARE
type list_varray is varray(8) of varchar2(50);
v_info list_varray := list_varray('shanghai','changan','facebook');
BEGIN
dbms_output.put_line(v_info(''));
dbms_output.put_line(v_info('a'));
exception
when value_error then
dbms_output.put_line('索引值类型错误');
end;
/ declare
type info_index is table of varchar2(100) index by PLS_INTEGER;
v_info info_index;
begin
v_info(1) := 'fireof';
v_info(2) := 'firefox.com';
v_info(3) := 'www.firefox.com';
v_info.delete(1);
dbms_output.put_line(v_info(1));
dbms_output.put_line(v_info(2));
dbms_output.put_line(v_info(3));
exception
when no_data_found then
dbms_output.put_line('data not found !!!');
end;
/

oracle开发学习篇之集合运算符以及集合异常捕获的更多相关文章

  1. oracle开发学习篇之集合函数

    集合函数; declare type list_nested ) not null; v_all list_nested := list_nested('changan','hubei','shang ...

  2. Oracle 多表查询、查询运算符和集合运算

    一.多表查询 1.内连接 一般使用INNER JOIN关键字指定内连接,INNER可以省略,默认表示内连接.查询结果中只包含两表的公共字段值相等的行,列可以是两表中的任意列 2.外连接 包括左外连接. ...

  3. [adb 学习篇] python将adb命令集合到一个工具上

    https://testerhome.com/topics/6938 qzhi的更全面,不过意思是一样的,另外补充一个开源的https://github.com/264768502/adb_wrapp ...

  4. Oracle DBA学习篇之SQL_TRACE

    SQL_TRACE ; ; set serveroutput on; alter session set sql_trace=true; select count(*) from firefox; a ...

  5. ASP.NET Core Web开发学习笔记-1介绍篇

    ASP.NET Core Web开发学习笔记-1介绍篇 给大家说声报歉,从2012年个人情感破裂的那一天,本人的51CTO,CnBlogs,Csdn,QQ,Weboo就再也没有更新过.踏实的生活(曾辞 ...

  6. Unity 3D游戏开发学习路线(方法篇)

    Unity 3D本来是由德国的一些苹果粉丝开发的一款游戏引擎,一直只能用于Mac平台,所以一直不被业外人士所知晓.但是后来也推出了2.5版,同时发布了PC版本,并将其发布方向拓展到手持移动设备.Uni ...

  7. iOS开发Swift篇—(四)运算符

    iOS开发Swift篇—(四)运算符 一.运算符 1.Swift所支持的部分运算符有以下一些 赋值运算符:= 复合赋值运算符:+=.-= 算术运算符:+.-.*./ 求余运算符:% 自增.自减运算符: ...

  8. 李洪强iOS开发Swift篇—04_运算符

    李洪强iOS开发Swift篇—04_运算符 一.运算符 1.Swift所支持的部分运算符有以下一些 赋值运算符:= 复合赋值运算符:+=.-= 算术运算符:+.-.*./ 求余运算符:% 自增.自减运 ...

  9. 跟Google学习Android开发-起始篇-构建你的第一个应用程序(4)

    说明:此系列教程翻译自Google Android开发者官网的Training教程,利用Chome浏览器的自动翻译功能作初译,然后在一些语句不顺或容易造成误解的地方作局部修正.方便英文不好的开发者查看 ...

随机推荐

  1. 解决eclipse Debug时提示source not found的问题

    解决办法: 选择Change Attached  Source,添加自己的project,clean项目,重启eclipse即可.

  2. win、mac系统配置本地电脑ip为域名教程

    win系统: 如何修改hosts文件 主机文件原内容如下: #Copyright(c)1993-2009 Microsoft Corp. # #这是Windows的Microsoft TCP / IP ...

  3. HTML语义化(2016/3/16更新)

    目录 什么是HTML语义化? 为什么要语义化 常用标签的语义 HTML5新元素 一.什么是HTML语义化? 简单来讲就是:每个标签做自己的事,使得能够被机器直接读懂. 二.为什么要语义化? 1.更容易 ...

  4. java基础72 junit单元测试

    1.junit要注意的细节 1.如果junit测试一个方法,在junit窗口上显示绿色代表测试成功:如果显示红条,则代表测试方法出现异常不通过.    2.如果点击方法名.包名.类名.工程名运行jun ...

  5. 错误/异常:The project cannot be built until build path errors are resolved 和 Unbound classpath container: 'JRE System Library [JavaSE-1.7]' in project 'MyJavaCode';的解决方法

    错误1: The project cannot be built until build path errors are resolved 解决方法: 把java的类库加载进去即可,在工程上右键 选择 ...

  6. Knockout.Js官网学习Demo(使用VS2012或者VS2013均可打开)

    https://pan.baidu.com/s/1gf9JZ8n#list/path=%2F

  7. Linux下的文件与目录权限

    一.用户(User).群组(Group)和其他人(Others) linux是多用户多任务的操作系统,同一时刻可能会有多个用户登录系统,考虑到文件的安全性等问题,所以Linux下的文件都属于一个特定的 ...

  8. PHP学习日记 函数

    可变函数 PHP支持可变函数的概念.所以如果一个变量后面有圆括号“()”,PHP将寻找与变量值同名的函数,并尝试执行此函数,可变函数可以用来实现回调函数.函数列表等.可变函数不能用于echo.prin ...

  9. thinphp中auth认证方法使用

    一.获取Auth类1.ThinkPHP3.1.3完整版:http://www.thinkphp.cn/down/338.html2.OneThink1.0正式版:https://github.com/ ...

  10. STM32 串口通信

    1. 中断说明 TXE(Tansmit Data Register empty interrupt) - 发送数据寄存器空,产生中断.当使能TXE后,只要Tx DR空了,就会产生中断.---写寄存器D ...