Home » SQL & PL/SQL » SQL & PL/SQL » Handle exception Invalid identifier (11.2.0.3.0)
Handle exception Invalid identifier [message #578336] Wed, 27 February 2013 01:52 Go to next message
rishwinger
Messages: 132
Registered: November 2011
Senior Member
Hi Experts,

In my code i am selecting a column which does not exist for a table so i m trying to handle that error in exception handler but i am getting error Please help

I want to handle ORA-00904 invalid identifier error

DECLARE
  l_count                      INTEGER:=0;
  invalid_identifier_exception EXCEPTION;
  PRAGMA EXCEPTION_INIT (invalid_identifier_exception, -06550);
  invalid_identifier_exception1 EXCEPTION;
  PRAGMA EXCEPTION_INIT (invalid_identifier_exception1, -00904);
  huge_quantity EXCEPTION;
BEGIN
  SELECT COUNT(*) INTO l_count FROM emp WHERE deptno=10;
  IF l_count=0 THEN
    GOTO mybrg;
    RAISE huge_quantity;
  END IF;
  SELECT sdsd FROM emp;
  <<mybrg>> NULL;
EXCEPTION
WHEN huge_quantity THEN
  --DBMS_OUTPUT.PUT_LINE ('no fxn');
  raise_application_error(-2100, 'The number of unit is above the discount limit.');
WHEN invalid_identifier_exception THEN
  DBMS_OUTPUT.PUT_LINE ('Unexpected error');
WHEN invalid_identifier_exception1 THEN
  DBMS_OUTPUT.PUT_LINE ('Unexpected error');
WHEN OTHERS THEN
  DBMS_OUTPUT.PUT_LINE ('Unexpected error odr');
END;
/



select sdsd from emp;
       *
ERROR at line 14:
ORA-06550: line 14, column 8:
PL/SQL: ORA-00904: "SDSD": invalid identifier
ORA-06550: line 14, column 1:
PL/SQL: SQL Statement ignored



Re: Handle exception Invalid identifier [message #578337 is a reply to message #578336] Wed, 27 February 2013 01:57 Go to previous messageGo to next message
delna.sexy
Messages: 941
Registered: December 2008
Location: Surat, The Diamond City
Senior Member
EXCEPTION section is given to process run time exceptions, not compile time exception.

regards,
Delna
Re: Handle exception Invalid identifier [message #578338 is a reply to message #578336] Wed, 27 February 2013 01:57 Go to previous messageGo to next message
Michel Cadot
Messages: 58855
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
The error raises at compilation time.
Your exception handlers trap the execution errors.

Regards
Michel
Re: Handle exception Invalid identifier [message #578341 is a reply to message #578338] Wed, 27 February 2013 02:11 Go to previous message
rishwinger
Messages: 132
Registered: November 2011
Senior Member
Thank you Delna and Michel for clearing my concepts

I wasted my half day for this to work
Previous Topic: Auto generation Number
Next Topic: Calling other procedures from autonomous procedure
Goto Forum:
  


Current Time: Thu Aug 21 11:53:16 CDT 2014

Total time taken to generate the page: 0.10696 seconds