oracle plsql exception例外
以下plsql程序用的scott用户的dept,emp表。
not_data_found例外:
--系统列外
set serveroutput on declare pename emp.ename%type; begin select ename into pename from emp where empno =1234; exception
when no_data_found then dbms_output.put_line('没有查到数据');
when others then dbms_output.put_line('其他'); end;
/
too_many_rows例外:
--系统例外: too_many_rows set serveroutput on
declare pename emp.ename%type; begin select ename into pename from emp where deptno = 10; exception
when too_many_rows then dbms_output.put_line('select into 匹配多行');
when others then dbms_output.put_line('其他');
end;
/
算数或转换例外:
--系统例外 : value_error set serveroutput on declare pnum number;
begin
pnum := 'abc'; exception
when value_error then dbms_output.put_line('算术或转换错误');
when others then dbms_output.put_line('其他');
end;
/
0不能做除数例外:
--系统例外 zero_divide
set serveroutput on declare pnum number;
begin pnum := 1/0; exception
when zero_divide then dbms_output.put_line('0不能做除数');
when others then dbms_output.put_line('其他');
end;
/
自定义例外:
--自定义例外: set serveroutput on declare cursor cemp is select ename from emp where deptno =50;
pename emp.ename%type; --自定义列外
not_emp_data exception; begin
open cemp; fetch cemp into pename; if cemp%notfound then
raise not_emp_data;
end if;
--如果程序程序中出现例外,oracle会通过pmon(process monitor)自动关闭清理资源
close cemp; exception
when not_emp_data then dbms_output.put_line('自定义例外:没有查询到数据');
when others then dbms_output.put_line('其他列外');
end;
/
知识点出处:http://www.imooc.com/learn/360
oracle plsql exception例外的更多相关文章
- Oracle PLSQL读取(解析)Excel文档
http://www.itpub.net/thread-1921612-1-1.html !!!https://code.google.com/p/plsql-utils/ Introduction介 ...
- Oracle/PLSQL存储过程详解
原文链接:https://blog.csdn.net/zezezuiaiya/article/details/79557621 Oracle/PLSQL存储过程详解 2018-03-14 17:31: ...
- Oracle/PLSQL: ORA-06550
参考: http://blog.csdn.net/haiross/article/details/20612135 Oracle/PLSQL: ORA-06550 Learn the cause an ...
- MyEclipse+Weblogic+Oracle+PLSQL配置注意事项
Weblogic配置详情:<Weblogic安装与配置图文详解>Oracle+PLSQL配置详情:<PL/SQL访问远程Oracle服务器(多种方式)>MyEclipse配置: ...
- oracle Plsql 运行update或者delete时卡死问题解决的方法
oracle Plsql 运行update或者delete时 遇到过Plsql卡死问题或者导致代码运行sql的时候就卡死. 在开发中遇到此问题的时候,本来把sql复制出来,在plsql中运行,Sql本 ...
- oracle plsql基本语法
oracle plsql 基本语法 --plsql默认规则:plsql赋值用":=" plsql判断用"=" plsql输入用"&" ...
- Oracle PLSQL语句实例
/** * plsql:某个项目对效率要求比较高的时候用,一般不用,大多数项目写的是夸数据库平台的,用不上. * pssql大多数能做的东西,java都能替代它.在某些特殊的地方要求用plsql的时候 ...
- Oracle plsql存储过程中out模式参数的用法
在plsql中,存储过程中的out模式的参数可以用来返回数据,相当于函数的返回值.下面是一个小例子. 沿用上一篇的emp表结构和数据. 存储过程如下: create or replace proced ...
- oracle plsql 捕获异常和抛出异常
在写oracle存储过程的时候很多东西放到存储过程里面比如一些判断等,要比在程序逻辑里面简单很多,但是也会涉及到捕获和抛出一样的问题. 捕获异常 语法: 首先定义异常: <异常情况> E ...
随机推荐
- centos 6 网卡名称修改
centos6 中网卡的名字有时不是eth0,这时就会带来诸多不便,为此需要修改网卡的名称. 修改网卡名称vim /etc/sysconfig/network-scripts/ifcfg-eno167 ...
- 前端请求参数MD5加密校验,参数串解密
首先引入MD5加密库:=>https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js; 步骤:=>1.请求前对参数进行字典升序排序,排 ...
- Codeforces 915E Physical Education Lessons
原题传送门 我承认,比赛的时候在C题上卡了好久(最后也不会),15min水掉D后(最后还FST了..),看到E时已经只剩15min了.尽管一眼看出是离散化+线段树的裸题,但是没有时间写,实在尴尬. 赛 ...
- bzoj:2018 [Usaco2009 Nov]农场技艺大赛
Description Input 第1行:10个空格分开的整数: N, a, b, c, d, e, f, g, h, M Output 第1行:满足总重量最轻,且用度之和最大的N头奶牛的总体重模M ...
- [bzoj2462] [BeiJing2011]矩阵模板
二维的hash.. 注意n的范围是1000........ 真相似乎是全部输出1就行了233 #include<cstdio> #include<iostream> #incl ...
- hdu_4869(费马小定理+快速幂)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4869 Turn the pokers Time Limit: 2000/1000 MS (Java/O ...
- javascript 指定绑定函数名称,并且传递参数
<html> <head> <title> New Document </title> <script type="text/jav ...
- DedeCMS首页调用缩略图为背景
配合{dede:arclist}{/dede:arclist}标签使用,既可以实现把缩略图作为背景,另外还需要用到background-position这个标签,做好背景的定位. http://www ...
- 用Dedecms5.7的arclist标签调用文章内容
arclist标签调用文章内容 首先大家都知道在Dedecms中,list标签是可以调用文章内容的,调用格式就不再此冗述了.从我个人来说,我非常不喜欢用list标签调用,有可能我会尽量使用arclis ...
- 有经验JAVA程序员如何提升自己?
作为一个具有一到五年开发经验程序员,需要学习内容很多: JVM/分布式/高并发/性能优化/Spring MVC/Spring Boot/Spring Cloud/MyBatis/Netty源码分析等等 ...