Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to catch PL/SQL: ORA-00904 error?

HARMEETKAURJul 28 2010 — edited Jul 28 2010
Hi ,
I am trying to run the following PL/SQL Block and have trapped error code -904( for invalid column name) in the exception section block.

The column name in the select query does not exist in the emp table and as per my understanding since I have an exceptiion handler for this error it should be handled in Exception Block.

DECLARE
invalid_column exception;
pragma exception_init (invalid_column,-00904);
no number;
BEGIN
select empn into no from emp
where ename='king';
EXCEPTION
when invalid_column then
dbms_output.put_line(Column ane does not exist)
);
end;
/

1) Can You please let me know why this is not getting caught in Exception handler
*2) What changes should I make in Exception handler section so that Invalid column name is handled in the program*
Thanks and regards
Harmeet
This post has been answered by Saubhik on Jul 28 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 25 2010
Added on Jul 28 2010
6 comments
5,405 views