How to catch a unique constraint error in a PL/SQL block?

后端 未结 4 864
情深已故
情深已故 2021-02-01 01:39

Say I have an Oracle PL/SQL block that inserts a record into a table and need to recover from a unique constraint error, like this:

begin
    insert into some_ta         


        
4条回答
  •  清歌不尽
    2021-02-01 02:31

    I suspect the condition you are looking for is DUP_VAL_ON_INDEX

    EXCEPTION
        WHEN DUP_VAL_ON_INDEX THEN
            DBMS_OUTPUT.PUT_LINE('OH DEAR. I THINK IT IS TIME TO PANIC!')
    

提交回复
热议问题