Monday 29 July 2013

What is Pragma EXECPTION_INIT? Explain the usage?

Pragma exception_init Allow you to handle the Oracle predefined message by your own message. Means you can instruct compiler to associate the specific message to oracle predefined message at compile time. This way you improve the Readability of your program, and handle it according to your own way.

It should be declare at the DECLARE section.

declare
salary number;
FOUND_NOTHING exception;
Pragma exception_init(FOUND_NOTHING ,100);
begin
select sal in to salary from emp where ename ='ANURAG';
dbms_output.put_line(salary);
exception
WHEN FOUND_NOTHING THEN
dbms_output.put_line(SQLERRM);
end;

No comments:

Post a Comment