How can we print the error code in exception handling section?

Questions by madhug56   answers by madhug56

Showing Answers 1 - 9 of 9 Answers

EXCEPTION
WHEN No_privilages THEN
htp.p( '<H1> Access denied</H1>');
WHEN Rec_expired THEN
htp.p('Other user has changed this record,Query the record and
Update');
WHEN OTHERS THEN
Htp.p(SQLERRM);

  Was this answer useful?  Yes

devi

  • Sep 25th, 2007
 

You can print the 'sqlcode' as follows

Exception 
When others then
dbms_output.put_line('error code is'||sqlcode)
end; 

  Was this answer useful?  Yes

EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20001,An error was encountered - ||SQLCODE|| -ERROR- ||SQLERRM);
END;
Or you could log the error to a table using the SQLERRM function as follows:
EXCEPTION
WHEN OTHERS THEN
err_code := SQLCODE;
err_msg := SUBSTR(SQLERRM, 1, 200);
INSERT INTO audit_table (error_number, error_message)
VALUES (err_code, err_msg);
END;

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions