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 truncate table?
1)what is the difference between Reinitializing a Subscription and synchronization the subscription? 2)when to use reinitializing ? 3)when to use synchronization? 4)when adding table or deleting a table what to do?(reinz.. or syn) 5)when adding a column what to do?
What is a coalesce function?
What do you understand by a view?
Find nth lowest salary or get nth lowest salary?
What is a data source or ds? : sql server analysis services, ssas
What are the properties of sub-query?
How to create new table with "create table" statements?
What is difference between drop truncate and delete?
What are the different normalization forms?
What are relationships and mention different types of relationships in the dbms
What are the properties of the transaction?
How to rename an existing table with the "sp_rename" stored procedure in ms sql server?
Do you know what are the differences between lost updates and uncommitted dependencies?
How to select some specific columns from a table in a query in ms sql server?