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 do you drop an index?
Can we hide the definition of a stored procedure from a use?
What is 3nf normalization?
What is difference between line feed ( ) and carriage return ( )?
How to change the ownership of a schema in ms sql server?
How do I find my localdb version?
What is #temp and @table variable in SQL server?
there is a trigger defined for insert operations on a table, in an oltp system. The trigger is written to instantiate a com object and pass the newly inserted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better? : Sql server database administration
What is BLOCK statements in SQL?
How to scale out a federation by Sql statement?
How to convert a numeric expression from one data type to another?
What is indexed view? How to create it?
What is sql server programming?
What are the new features in SQL Server 2005 when compared to SQL Server 2000?
Explain what role entity and relationship play in an ER diagram.