How to handle errors in Stored Procedures.
Answer Posted / saraswathi muthuraman
If the procedure execution fails the oracle will quit the
execution with an error.
This error can be handled with in store procedure using
"exception".
declare
test_excep_name exception;
x number;
Begin
select emp_no into x from emp_test where emp_no=1;
If SQL%NOTFOUND then
raise test_excep_name;
end if;
exception
when test_excep_name then
dbms_output.put_line(' Error occurred during execution' || '
SQL error code is ' || sqlcode || ' SQL error maessage '||
sqlerrm);
when others then
dbms_output.put_line(' Error occurred during execution- This
is unknown error ' || ' SQL error code is ' || sqlcode || '
SQL error maessage '|| sqlerrm);
end;
/
Result :
Error occurred during execution- This is unknown error SQL
error code is 100
SQL error maessage ORA-01403: no data found
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How does using a separate hard drive for several database objects improves performance right away?
How to populate a table in sql server?
What is Cross Join and in which scenario do we use Cross Join?
What is conditional split?
how to control the amount of free space in your index pages? : Sql server database administration
How do I view a trc file?
What do you understand by recursive stored procedures?
Can we delete data from a view?
What are commit and rollback in sql?
What is unpivot?
Explain the difference between control flow and data flow?
What happens if an integer is too big for int date type?
Explain indexes disadvantages?
Which feature in sql server 2008 has surprised you? You can name just one. : sql server database administration
How to drop an existing user defined function in ms sql server?