zoukankan      html  css  js  c++  java
  • PL/SQL异常

     CASE_NOT_FOUND

    CASE selector
    WHEN selector_value_1 THEN statements_1
    WHEN selector_value_2 THEN statements_2
    ...
    WHEN selector_value_n THEN statements_n
    [ ELSE
      else_statements ]
    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.

    CASE
    WHEN condition_1 THEN statements_1
    WHEN condition_2 THEN statements_2
    ...
    WHEN condition_n THEN statements_n
    [ ELSE
      else_statements ]
    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.

    DECLARE
    grade CHAR(1);
    BEGIN
    grade := 'B';
    CASE
    WHEN grade = 'A' THEN DBMS_OUTPUT.PUT_LINE('Excellent');
    WHEN grade = 'B' THEN DBMS_OUTPUT.PUT_LINE('Very Good');
    WHEN grade = 'C' THEN DBMS_OUTPUT.PUT_LINE('Good');
    WHEN grade = 'D' THEN DBMS_OUTPUT.PUT_LINE('Fair');
    WHEN grade = 'F' THEN DBMS_OUTPUT.PUT_LINE('Poor');
    END CASE;
    EXCEPTION
    WHEN CASE_NOT_FOUND THEN
    DBMS_OUTPUT.PUT_LINE('No such grade');
    END;
    /

     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.

  • 相关阅读:
    169. Majority Element
    283. Move Zeroes
    1331. Rank Transform of an Array
    566. Reshape the Matrix
    985. Sum of Even Numbers After Queries
    1185. Day of the Week
    867. Transpose Matrix
    1217. Play with Chips
    766. Toeplitz Matrix
    1413. Minimum Value to Get Positive Step by Step Sum
  • 原文地址:https://www.cnblogs.com/freewater/p/3115198.html
Copyright © 2011-2022 走看看