CASE_NOT_FOUND

  1. CASE selector
  2. WHEN selector_value_1 THEN statements_1
  3. WHEN selector_value_2 THEN statements_2
  4. ...
  5. WHEN selector_value_n THEN statements_n
  6. [ ELSE
  7. else_statements ]
  8. END CASE;]

The simple CASE statement runs the first statements for which selector_value equals selector. Remaining conditions are not evaluated. If no selector_value equals selector, the CASE statement runs else_statements if they exist and raises the predefined exception CASE_NOT_FOUND otherwise.

  1. CASE
  2. WHEN condition_1 THEN statements_1
  3. WHEN condition_2 THEN statements_2
  4. ...
  5. WHEN condition_n THEN statements_n
  6. [ ELSE
  7. else_statements ]
  8. END CASE;]

The searched CASE statement runs the first statements for which condition is true. Remaining conditions are not evaluated. If no condition is true, the CASE statement runs else_statements if they exist and raises the predefined exception CASE_NOT_FOUND otherwise.

  1. DECLARE
  2. grade CHAR(1);
  3. BEGIN
  4. grade := 'B';
  5. CASE
  6. WHEN grade = 'A' THEN DBMS_OUTPUT.PUT_LINE('Excellent');
  7. WHEN grade = 'B' THEN DBMS_OUTPUT.PUT_LINE('Very Good');
  8. WHEN grade = 'C' THEN DBMS_OUTPUT.PUT_LINE('Good');
  9. WHEN grade = 'D' THEN DBMS_OUTPUT.PUT_LINE('Fair');
  10. WHEN grade = 'F' THEN DBMS_OUTPUT.PUT_LINE('Poor');
  11. END CASE;
  12. EXCEPTION
  13. WHEN CASE_NOT_FOUND THEN
  14. DBMS_OUTPUT.PUT_LINE('No such grade');
  15. END;
  16. /

VALUE_ERROR

The lower and upper bounds of a FOR LOOP statement can be either numeric literals, numeric variables, or numeric expressions. If a bound does not have a numeric value, then PL/SQL raises the predefined exception VALUE_ERROR.

存储过程死循环

1.找到运行存储过程的session

select * from v$session;

如果长时间运行,

select * from v$locked_object;

2.删除该会话

alter system kill session 'sid,serial#';

NO_DATA_FOUND

If the SELECT INTO statement returns no rows, PL/SQL raises the predefined exception NO_DATA_FOUND immediately, before you can check SQL%NOTFOUND.

TOO_MANY_ROWS

If a SELECT INTO statement without a BULK COLLECT clause returns multiple rows, PL/SQL raises the predefined exception TOO_MANY_ROWS

INVALID_CURSOR

After closing a cursor, you cannot fetch records from its result set or reference its attributes. If you try, PL/SQL raises the predefined exception INVALID_CURSOR.

If an explicit cursor is not open, referencing any attribute except %ISOPEN raises the predefined exception INVALID_CURSOR.

CURSOR_ALREADY_OPEN

You can reopen a closed cursor. You must close an explicit cursor before you try to reopen it. Otherwise, PL/SQL raises the predefined exception CURSOR_ALREADY_OPEN.

ROWTYPE_MISMATCH

After opening a cursor variable, you can fetch the rows of the query result set with the FETCH statement.

The return type of the cursor variable must be compatible with the into_clause of the FETCH statement. If the cursor variable is strong, PL/SQL catches incompatibility
at compile time. If the cursor variable is weak, PL/SQL catches incompatibility at run time, raising the predefined exception ROWTYPE_MISMATCH before the first fetch.

DUP_VAL_ON_INDEX

The DUP_VAL_ON_INDEX Exception (ORA-00001) occurs when a program attempts to store a duplicate value or values in a database column that is constrained by a unique index.

PL/SQL异常的更多相关文章

  1. oracle学习笔记(十六) PL/SQL 异常和goto语句

    PL/SQL 异常和goto语句 异常 预定义异常 oracle常见预定义异常: 错误号 异常错误信息名称 说明 ORA-0001 DUP_VAL_ON_INDEX 试图破坏一个唯一性限制 ORA-0 ...

  2. Oracle PL/SQL异常、存储过程和触发器

    一.异常 1.处理异常 (1)除数不为0 declare b number; begin b:; exception when zero_divide then dbms_output.put_lin ...

  3. PL/SQL 异常错误处理

     异常错误处理 一个优秀的程序都应该可以正确处理各种出错情况,并尽可能从错误中恢复.ORACLE 提供异常情况(EXCEPTION)和异常处理(EXCEPTION HANDLER)来实现错误处理 ...

  4. PL/SQL 异常处理程序

     异常处理程序 一个好的程序应该能够妥善处理各种错误情况,并尽可能从错误中恢复.ORACLE 提供异常(EXCEPTION)和异常处理(EXCEPTION HANDLER)错误处理 ①有三种类型的 ...

  5. PL/SQL异常获取

    1.no_data SET SERVEROUTPUT ON DECLARE pename EMP.ENAME % TYPE ; BEGIN SELECT ename INTO pename FROM ...

  6. PL\SQL结构控制、异常

    PL\SQL结构控制    1.IF条件控制语句(三种基本方式+IF语句的嵌套使用)        (1)IF...        (2)IF...ELSE        (3)IF...ELSIF. ...

  7. Oracle PL/SQL中异常高级特性

    在OraclePL/SQL语句块中exception的异常处理部分是非常重要的组成部分,它决定了在PL/SQL语句块内部可执行部分在发生异常错误时,程序是友好地提示:程序遇到某些错误而无法执行,还是抛 ...

  8. PL/SQL异常处理方法

    PL/SQL异常处理方法   1:什么是异常处理: PL/SQL提供一个功能去处理异常,在PL/SQL块中叫做异常处理,使用异常处理我们能够测试代码和避免异常退出. PL/SQL异常信息包含三个部分: ...

  9. 整理课堂笔记 pl/sql orcale异常

      1>>>>>异常错误处理 1 >预定义的异常处理 预定义说明的部分 ORACLE 异常错误对这种异常情况的处理,只需在PL/SQL块的异常处理部分,直接引用相应 ...

随机推荐

  1. Java中的Set, List, Map漫谈

    在编程语言中,集合是指代表一组对象的对象.Java平台专门有一个集合框架(Collections Framework).集合框架是指表示和操作集合的统一架构,隔离了集合的操作和实现细节. 集合框架中的 ...

  2. [BTS] Faulting application name: BTSNTSvc.exe, version: 3.9.469.0, time stamp: 0x4c547e09

    Log Name: ApplicationSource: Application ErrorDate: 8/22/2013 1:28:35 AMEvent ID: 1000Task Category: ...

  3. Atitit.基于dsl的methodinvoker

    Atitit.基于dsl的methodinvoker V2 new dyn  invoke V3 plan Meth chain Prj  cms methd_invok.bat rem a  sta ...

  4. UIBarButtonItem-添加自定义Left或者Right按钮

    为UINavigationController添加UINavigationItem,我们可以这样写:   1.添加返回导航按钮backBarButtonItem   1.用系统自带的返回按钮 UIBa ...

  5. IIS7显示ASP的详细错误信息到浏览器

    服务端环境:Windows2008 + IIS7 客户端浏览器设置:取消“显示友好的HTTP错误信息” IIS7设置(GUI): 1. 网站->ASP->调试属性->将错误发送到浏览 ...

  6. Visual Studio 2012完美的拥抱GitHub

    详情请查看http://www.aehyok.com/Blog/Detail/73.html 个人网站地址:aehyok.com QQ 技术群号:206058845,验证码为:aehyok 本文文章链 ...

  7. Spring 整合 Flex (BlazeDS)无法从as对象 到 Java对象转换的异常:org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.Date' to required type 'java.sql.Timestamp' for property 'wfsj'; nested exception is java.lang.Ill

    异常信息如下: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value ...

  8. ASSIC码对照表

    编码对应字符: ✔:\u2714✘:\u2718 <script type="text/javascript"> var aaa = "\u2718" ...

  9. PHOTOSHOP CC 2015插件安装方法

    收到很多评论说不能安装.抱歉,这里解释一下,不是所有插件都能用这个方法,安装不了的只能等插件更新了,这里只是给大家一个尝试的方法,有一些插件可以用这个方法安装. 试试嘛,如果懒得试,可以忽略这篇文章. ...

  10. Core Java - 流(Stream) - 字节流和字符流(一)

    0. 概述: Java中基于流的I/O构建在4个抽象类之上, 其中2个是字节流,另外2个是字符流. 字节流: InputStream / OutputStream 当操作字节或其它二进制对象时,应当使 ...