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
Tell me what are the advantages of using stored procedures?
What are the differences between substr and charindex in sql server.
Can you explain what is sql server english query?
What is sql server english query?
Is truncate autocommit?
What is tablesample?
Please explain what is “asynchronous” communication in sql server service broker?
What are trace flags and mention a few common trace flags used with sql server?
What is the optimization being performed in oracle and SQL Server?
What is the use of RDBMS?
What is indexing explain it with an example?
What are the different authentication modes in sql server? How can it be changed?
What are the different types of normalization?
where can you add custom error messages to sql server? : Sql server administration
How sql server enhances scalability of the database system?