Monday, December 17, 2018

What is Pragma EXECPTION_INIT? Explain the usage?

Pragma exception_init Allows you to handle the Oracle predefined message with your own message. This means you can instruct the compiler to associate the specific message to the oracle's 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 declared in the DECLARE section.

declare
salary number;
FOUND_NOTHING exception;
Pragma exception_init(FOUND_NOTHING ,100);
begin
select sal into 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