Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reg: Exception Handling

EV259Jan 22 2014 — edited Jan 22 2014

Dear All,

When I executed the below plsql block i got the error. Not sure,  'ORA-06510: PL/SQL: unhandled user-defined exception', why it is coming.

When No data found, I am raising my own exception "userException". I am bit confused. Request all to explain.

DECLARE
  userException EXCEPTION;
  v_name emp.ename%type;
  v_err VARCHAR2(200);
BEGIN
  ----------------- statement
  BEGIN
    SELECT ename INTO v_name FROM emp WHERE empno = 1;
  EXCEPTION
  WHEN no_data_found THEN
    v_err := 'No data found for the employee';
    raise userException;
  WHEN OTHERS THEN
    v_err := 'Others Exception';
    raise userException;
  END;
EXCEPTION
WHEN userException THEN
  raise_application_error(-20901, v_err, TRUE);
END;


Error report:
ORA-20901: No data found for the employee
ORA-06512: at line 19
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-01403: no data found

This post has been answered by Karthick2003 on Jan 22 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 19 2014
Added on Jan 22 2014
5 comments
2,148 views