--取出集合;长度
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. ROS二进制日志包 ROS binary logger package

    原文网址: 1 http://www.ros.org/news/2017/02/ros-binary-logger-package.html 2 https://github.com/CNR-ITIA ...

  2. 2016-2017-2 20155309南皓芯java第四周学习总结

    教材内容总结 这次我们学习的还是两章的内容,学习任务量跟上次比的话大体上来讲是差不多的. 继承与多态 继承 继承也符合DRY(Don't Repeat Yourself)原则 Role role1 = ...

  3. Windows平台的rop exp编写

    摘抄自看雪 Windows的ROP与Linux的ROP并不相同,其实Linux下的应该叫做是ret2libc等等.Windows的ROP有明确的执行目标,比如开辟可执行内存然后拷贝shellcode, ...

  4. PHP性能调优---php-fpm - 启动参数及重要配置详解

    约定几个目录/usr/local/php/sbin/php-fpm/usr/local/php/etc/php-fpm.conf/usr/local/php/etc/php.ini 一,php-fpm ...

  5. PHP性能调优---PHP-FPM配置及使用总结

    PHP-FPM配置及使用总结: php-FPM是一个PHP FastCGI的管理器,它实际上就是PHP源代码的补丁,旨在将FastCGI进程管理引进到PHP软件包中,我们必须将其patch到PHP源代 ...

  6. Winsock—I/O模型之选择模型(一)

    Winsock中提供了一些I/O模型帮助应用程序以异步方式在一个或多个套接字上管理I/O. 这样的I/O模型有六种:阻塞(blocking)模型,选择(select)模型,WSAAsyncSelect ...

  7. PHP开发命名规范

    命名规范 ThinkPHP5遵循PSR-2命名规范和PSR-4自动加载规范,并且注意如下规范: 目录和文件 目录使用小写+下划线: 类库.函数文件统一以.php为后缀: 类的文件名均以命名空间定义,并 ...

  8. Java 集合补充

    集合大致可以分List,Set,Queue,Map四种体系. 集合和数组不一样,数组元素可以是基本类型的值,也可以是对象(的引用变量),集合里只能保存对象(的引用变量). 访问:如果访问List集合中 ...

  9. [漏洞复现]CVE-2010-2883 Adobe Reader 打开pdf电脑即刻中招

    1.漏洞概述: CVE-2010-2883漏洞原理:“Adobe Reader在处理CoolType字体文件的sing表时,存在栈溢出漏洞,当打开特制的恶意PDF文件时,可允许任意代码远程执行.” 影 ...

  10. 【基础知识】.Net基础加强 第二天

    第02天 .Net基础加强 1. 封装 1> 属性的封装: 属性封装字段:把变化封装一下,保留用户的使用方式 2> 把方法的多个参数封装成一个对象 3> 将一堆代码封装到一个方法中 ...