亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

13.PL_SQL——異常處理

發布時間:2020-05-27 09:31:29 來源:網絡 閱讀:964 作者:wuyeyoulanjian 欄目:關系型數據庫

==================== Example 1====================

 

SQL> create table emp_tmp as select * from employees;

 

Table created.

 

SQL> select last_name from emp_tmp wherefirst_name='John';

 

LAST_NAME

-------------------------

Chen

Seo

Russell

 

SQL> edit

 

DECLARE

    v_lnameVARCHAR2(15);

BEGIN

    SELECT last_nameINTO v_lname

    FROM emp_tmp

    WHERE first_name ='John';

 

   DBMS_OUTPUT.PUT_LINE('John''s last name is: ' || v_lname);

END;

/

 

SQL> @notes/s62.sql

DECLARE

*

ERROR at line 1:

ORA-01422: exact fetch returns more than requested number ofrows

ORA-06512: at line 4

 

 

SQL> edit

 

DECLARE

    v_lnameVARCHAR2(15);

 

BEGIN

    SELECT last_nameINTO v_lname

    FROM emp_tmp

    WHERE first_name ='John';

 

   DBMS_OUTPUT.PUT_LINE('John''s last name is: ' || v_lname);

 

EXCEPTION

    WHEN TOO_MANY_ROWSTHEN

       DBMS_OUTPUT.PUT_LINE('Your select statement retrieved multiple rows.Condider using a cursor.');

    WHEN OTHERS THEN

       DBMS_OUTPUT.PUT_LINE('You meet an error!');

END;

/

 

SQL> @notes/s62.sql

Your select statement retrieved multiple rows. Condiderusing a cursor.

 

PL/SQL procedure successfully completed.

 

 

SQL> truncate table emp_tmp;

 

Table truncated.

 

SQL> @notes/s62.sql

You meet an error!

 

PL/SQL proceduresuccessfully completed


13.PL_SQL——異常處理

13.PL_SQL——異常處理

13.PL_SQL——異常處理

13.PL_SQL——異常處理

13.PL_SQL——異常處理

==================== Example 2====================

 

SQL> edit

 

 

DECLARE

    v_lnameVARCHAR2(15);

 

BEGIN

    SELECT last_nameINTO v_lname

    FROM emp_tmp

    WHERE first_name ='John';

 

   DBMS_OUTPUT.PUT_LINE('John''s last name is: ' || v_lname);

   <<welcomeback>>

   DBMS_OUTPUT.PUT_LINE('Welcome back!');

 

EXCEPTION

    WHEN TOO_MANY_ROWSTHEN

       DBMS_OUTPUT.PUT_LINE('Your select statement retrieved multiple rows.Condider using a cursor.');

    WHEN OTHERS THEN

       DBMS_OUTPUT.PUT_LINE('1: You meet an error!');

        GOTOwelcomeback;

       DBMS_OUTPUT.PUT_LINE('2: Game Over!');

       <<gohere>>

       DBMS_OUTPUT.PUT_LINE('3: You will be ended!');

END;

/

 

SQL> @notes/s63.sql

                GOTO welcomeback;

                *

ERROR at line 18:

ORA-06550: line 18, column 3:

PLS-00375: illegal GOTO statement; this GOTO cannot branchto label

'WELCOMEBACK'

ORA-06550: line 18, column 3:

PL/SQL: Statement ignored

 

 

SQL> edit

 

DECLARE

    v_lname VARCHAR2(15);

 

BEGIN

    SELECT last_nameINTO v_lname

    FROM emp_tmp

    WHERE first_name ='John';

 

   DBMS_OUTPUT.PUT_LINE('John''s last name is: ' || v_lname);

   <<welcomeback>>

   DBMS_OUTPUT.PUT_LINE('Welcome back!');

 

EXCEPTION

    WHEN TOO_MANY_ROWSTHEN

       DBMS_OUTPUT.PUT_LINE('Your select statement retrieved multiple rows.Condider using a cursor.');

    WHEN OTHERS THEN

       DBMS_OUTPUT.PUT_LINE('1: You meet an error!');

        --GOTOwelcomeback;

        GOTO gohere;

       DBMS_OUTPUT.PUT_LINE('2: Game Over!');

       <<gohere>>

 

       DBMS_OUTPUT.PUT_LINE('3: You will be ended!');

END;

 

 

SQL> @notes/s63.sql

1: You meet an error!

3: You will be ended!

 

PL/SQL proceduresuccessfully completed


13.PL_SQL——異常處理

13.PL_SQL——異常處理

13.PL_SQL——異常處理

13.PL_SQL——異常處理

13.PL_SQL——異常處理

13.PL_SQL——異常處理

13.PL_SQL——異常處理

13.PL_SQL——異常處理

13.PL_SQL——異常處理

==================== Example 3====================

 

SQL> edit

 

DECLARE

        e_insert_excepEXCEPTION;

 

        PRAGMAEXCEPTION_INIT(e_insert_excep, -01400);

 

BEGIN

        INSERT INTOdepartments(department_id, department_name) VALUES (280, NULL);

 

EXCEPTION

        WHENe_insert_excep THEN

                DBMS_OUTPUT.PUT_LINE('InsertOperation Failed!');

               DBMS_OUTPUT.PUT_LINE(SQLERRM);

END;

/

 

SQL> @notes/s64.sql

Insert Operation Failed!

ORA-01400: cannot insert NULL into("HR"."DEPARTMENTS"."DEPARTMENT_NAME")

 

PL/SQL proceduresuccessfully completed


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

阳高县| 阿荣旗| 临沂市| 缙云县| 贞丰县| 平度市| 鄂托克旗| 宿州市| 万全县| 灵石县| 浦城县| 阜新市| 阳新县| 观塘区| 成都市| 白山市| 顺义区| 九寨沟县| 普安县| 长泰县| 鄂温| 宁安市| 阿克苏市| 阜宁县| 大足县| 绥阳县| 尉犁县| 孟村| 孝义市| 怀来县| 右玉县| 呼图壁县| 交城县| 社会| 普格县| 阳江市| 泌阳县| 伊金霍洛旗| 务川| 鹿邑县| 杨浦区|