PL/SQL Exceptions on Update/Delete of non-existing row

后端 未结 3 886
太阳男子
太阳男子 2021-02-19 10:10

I am learning PL/SQL these days and currently working with Procedures and exceptions using oracle HR schema.

Here is my simple procedure.

create or rep         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-19 10:39

    I believe SQL%NOTFOUND returns true when no records are found. Your IF would evaluate to true in that case, and therefore write your put_line to terminal. The SQL statement executed successfully. If you execute that SQL statement by itself from command line, you will receive 0 rows updated/deleted, not an Oracle error.

    If you want to have an exception thrown, you could use RAISE inside your IF and point it to the exception in the exception block you want to have thrown.

提交回复
热议问题