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 to stop log file growing too big?
What are the properties of primary key?
On a windows server 2003 active – passive failover cluster, how do you find the node which is active?
What is a join in sql? What are the types of joins?
How do you trace the traffic hitting a sql server?
Define indexes?
Explain forward - only cursors?
How would you choose between a clustered and a non-clustered index?
How to get the query of a table in sql server?
Does windows server 2016 come with sql server?
Explain Normalization and DE normalization
List some case manipulation functions in sql?
How many database files are there in sql server 2000?what are they?
You are creating an application where users are asked their gender in the gender combo box you have three options: ‘male’ , ‘female’ and ‘i choose not to disclose’ these options are stored in the table as 1, 0 or null which datatype should you use?
How to create a user name in a database?