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
What is data compression?
How do you drop an index?
How to integrate the ssrs reports in application?
Why we use functions in sql server?
What is simple indexing method?
How to test subquery results with the exists operator?
On a windows server 2003 active – passive failover cluster, how do you find the node which is active?
Explain timestamp datatype?
what are user defined datatypes and when you should go for them? : Sql server database administration
What is sleeping status in sql server?
How to check if a table is being used in sql server?
How to convert a table data in XML format in sql server?
How many databases Microsoft SQL server provides?
What is the Disadvantage of indexed sequential file.
Why do you need a sql server?