1. Exception Classification: System exceptions, custom exceptions
(1) System exceptions, see related API documentation
(2) Custom exceptions
Define your own exceptions: As with custom variables, the type is exception
Exception thrown: Use raise to throw a custom exception
SetServeroutput onDeclare cursorCemp is SelectEname fromEmpwhereDeptno= -; Pename Emp.ename%type; --Self define exceptionSelf_no_data_found exception;begin OpenCemp; FetchCemp intoPename; ifCemp%NotFound Then --throw self Define exceptionraise Self_no_data_found; End if; exception whenSelf_no_data_found ThenDbms_output.put_line ('A custom exception was executed! '); ifCemp%IsOpen ThenDbms_output.put_line ('Close cursor! '); CloseCemp; End if; whenOthers ThenDbms_output.put_line ('others exception was performed! '); ifCemp%IsOpen Then CloseCemp; End if;End;/
Operation Result:
Oracle PL/SQL Learning Basics (2)-Exceptions