Home » SQL & PL/SQL » SQL & PL/SQL » raise_application_error message
raise_application_error message [message #338250] Mon, 04 August 2008 05:41 Go to next message
bhoite_amol83
Messages: 110
Registered: June 2005
Location: Pune
Senior Member
When i execute the below code it gives ,

ORA-20100: Provided Parent ID Is Not Present In Parent Table
ORA-06512: at line 11


But i need only output,

20100: Provided Parent ID Is Not Present In Parent Table


How can i do it?

DECLARE
	 p_exists NUMBER(1);
BEGIN
	   SELECT empno 
	   INTO p_exists 
	   FROM empl 
	   WHERE empno = 1 
	   AND ROWNUM = 1;
EXCEPTION
		 WHEN NO_DATA_FOUND THEN
			  		RAISE_APPLICATION_ERROR(-20100,'Provided Parent ID Is Not Present In Parent Table'); 
END;

ORA-20100: Provided Parent ID Is Not Present In Parent Table
ORA-06512: at line 11



Thanks,
Re: raise_application_error message [message #338256 is a reply to message #338250] Mon, 04 August 2008 05:52 Go to previous messageGo to next message
rajatratewal
Messages: 507
Registered: March 2008
Location: INDIA
Senior Member
Then Define your own custom exception.

Why you using Raise_Application_Error then??

Regards,
Rajat
Re: raise_application_error message [message #338258 is a reply to message #338250] Mon, 04 August 2008 05:58 Go to previous messageGo to next message
Michel Cadot
Messages: 64121
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You have to filter and transform the message by yourself, Oracle always provides the whole stack.

Regards
Michel
Re: raise_application_error message [message #338274 is a reply to message #338250] Mon, 04 August 2008 07:03 Go to previous messageGo to next message
Dipali Vithalani
Messages: 278
Registered: March 2007
Location: India
Senior Member

Or else, just print the error message (using dbms_output.put_line) instade of raising exception, if you just want the error message in case of failure..

Regards,
Dipali..
Re: raise_application_error message [message #338276 is a reply to message #338274] Mon, 04 August 2008 07:32 Go to previous message
Michel Cadot
Messages: 64121
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
And what will happen if the client does not activate dbms_output in its SQL*Plus session? He will just think everything was alright.

Regards
Michel
Previous Topic: Difference Between SQL & PLSQL
Next Topic: CLOB to LONG
Goto Forum:
  


Current Time: Wed Dec 07 02:45:16 CST 2016

Total time taken to generate the page: 0.12608 seconds