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 the difference between them (ethernet networks and token ring networks)? : Sql server database administration
How to delete an existing row with delete statements in ms sql server?
How to modify the underlying query of an existing view?
What happens if null values are involved in arithmetic operations?
Why would you use sql agent?
Tell me what are the advantages of using stored procedures?
What are transactions in sql?
Explain the difference between function and stored procedure?
Explain mixed authentication mode of sql server?
What is isnull() operator?
What are the types of indexing?
1.what is the diff between nolock optimizer and read uncommitted isolation? 2.what is the diff between revoke and deny? 3.what is percieved down time? 4.whether password protection are required for backups?if yes why?if no why? 5.what is fill factor? 6.what is cost analysis? 7.what is mean by piece meal restore? 8.what is 'rowguidcol'? 9.impersonate permission? 10.what is selectivity?
How to delete an existing database user?
What are the different authentication modes in sql server? How can it be changed?
What types of replication are supported in sql server?