ORACLE預存程序異常處理。

來源:互聯網
上載者:User

create or replace procedure p_tx_getfaxdata
(   
)
as
v_ErrorCode NUMBER;          -- 出錯的代碼
v_ErrorMsg  VARCHAR2(200);   -- 錯誤的訊息顯示
v_CurrentUser VARCHAR2(8);   -- 當前資料庫使用者
v_Information VARCHAR2(100); -- 關於錯誤的資訊

begin

  //do the things you need to do.

    commit;

    --異常捕捉
    Exception
        when others then
        begin
            v_ErrorCode := SQLCODE;
            v_ErrorMsg := SQLERRM;
            v_CurrentUser := USER;
            v_Information := '遇到了錯誤 ' || TO_CHAR(SYSDATE) || ' 資料庫使用者 ' || v_CurrentUser;
            dbms_output.put_line('執行錯誤,自動復原');
            dbms_output.put_line('詳細資料:'||'錯誤碼:'||v_ErrorCode||',錯誤訊息:'||v_ErrorMsg||',日誌資訊:'||v_Information);

             rollback;
        end;
end p_tx_getfaxdata;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.