--取出集合;长度
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. linux系统iostat命令详解

    iostat  -k 3 5  (以KB为单位,每3秒统计一次,共统计5次) • avg-cpu: 总体cpu使用情况统计信息,对于多核cpu,这里为所有cpu的平均值    %user    用户空 ...

  2. 【自用】bat ftp下载前一天备份

    @echo off rem 指定FTP用户名 set ftpUser=app rem 指定FTP密码 set ftpPass=app rem 指定FTP服务器地址 set ftpIP=192.168. ...

  3. Oracle 函数 “申请通过后,将该表中循环遍历到的所有内容插到另一个表中”

    create or replace function mcode_apply_insert_material(p_mca_no VARCHAR2, p_action VARCHAR2, p_wf_no ...

  4. Android Studio配置opencv

    安装过程参考:http://www.cnblogs.com/tail/p/4618476.html demo参考:http://blog.csdn.net/gao_chun/article/detai ...

  5. 如何使用 JMeter 调用你的 Restful Web Service?进行简单的压力测试和自动化测试

    表述性状态传输(REST)作为对基于 SOAP 和 Web 服务描述语言(WSDL)的 Web 服务的简单替代,在 Web 开发上得到了广泛的接受.能够充分证明这点的是主流 Web 2.0 服务提供商 ...

  6. Oracle 提示符

    http://blog.csdn.net/wyzxg/article/details/5647905

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

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

  8. HTML5元素1

    文档和元数据元素 元素 说明 类型 HTML5与其他的变化 base 设置相对URL的基础 元数据 无变化 body 表示HTML文档的内容 无 有变化 DOCTYPE 表示HTML文档的开始 无 有 ...

  9. java8 - 5

    import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.Lis ...

  10. mysql中的包含语句INSTR的使用

    1.目前测试百万级数据,效率还是相当可观,感觉比like更精准! 例句 今天项目遇到一个问题,每个用户都有自己的所属渠道,当登录后台操作时,要列出隶属于自己拥有渠道的用户列表,当初想到使用全部遍历出来 ...