Home » SQL & PL/SQL » SQL & PL/SQL » Raise_Application_Error (9i)
Raise_Application_Error [message #397024] Wed, 08 April 2009 12:09 Go to next message
MR[T]
Messages: 62
Registered: March 2009
Member
Hello Friends
I am unable to point out difference between RAISE_APPLICATION_ERROR and DBMS_OUTPUT.PUT_LINE .
here is an example program


 1  CREATE OR REPLACE PROCEDURE SHOW_EINFO(ECODE IN NUMBER) AS
  2  EI EMP%ROWTYPE;
  3  BN NUMBER:=0;
  4  BEGIN
  5   SELECT * INTO EI FROM EMP WHERE EMPNO=ECODE;
  6    BN:=CAL_BONUS(I.JOB,NVL(I.COMM,0)+NVL(I.SAL,0)); -- CALLING THE FUNCTION IN NAMED BLOCK.
  7    &D(EI.EMPNO||' '||EI.ENAME||' '||EI.JOB||' '||EI.SAL||' '||EI.COMM||' '||BN||' '||EI.DNAME);
  8  EXCEPTION
  9   WHEN NO_DATA_FOUND THEN
 10  RAISE_APPLICATION_ERROR(-20100,ECODE||' NOT EXIST IN EMPLOYEE TABLE...');
 11* END;
 12  /



In this Program when i am changing RAISE_APPLICATION_ERROR TO DBMS_OUTPUT.PUT_LINE .It generate an error.

But in another program ,exception is working with DBMS_OUTPUT.PUT_LINE instead of RAISE_APPLICATION_ERROR . here is the program ..,

DECLARE
 JID VARCHAR2(20) :='&DEIGNATION' ;
 EI EMP%ROWTYPE ;
BEGIN
 SELECT * INTO EI FROM EMP WHERE JOB=JID ;
&D(EI.EMPNO ||' '||EI.ENAME||' '||EI.SAL ) ;
EXCEPTION
 WHEN NO_DATA_FOUND THEN 
  &D(JID||' NOT EXISTS IN EMP TABLE ') ;
WHEN TOO_MANY_ROWS THEN
  &D(20100||'TOO MANY ROWS') ;
END ;

/

In this program if i change DBMS_OUTPUT.PUT_LINE to RAISE_APPLICATION_ERROR . It will generate error .

In both Program Exception of too_many_rows is used ,but one is working with RAISE_APPLICATION_ERROR AND another is working with DBMS_OUTPUT.PUT_LINE .
Please tell me the basic difference between these two KEYWORDS .
Re: Raise_Application_Error [message #397028 is a reply to message #397024] Wed, 08 April 2009 12:13 Go to previous messageGo to next message
pablolee
Messages: 2836
Registered: May 2007
Location: Scotland
Senior Member
Actually, it all works perfectly, and until you proffer proof that you are getting errors (that you are not showing us) from code (that you are bizarrely NOT showing us) I refuse to believe otherwise
Re: Raise_Application_Error [message #397029 is a reply to message #397024] Wed, 08 April 2009 12:14 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
In this Program when i am changing RAISE_APPLICATION_ERROR TO DBMS_OUTPUT.PUT_LINE .It generate an error.

So you did it wrong.
Don't describe, use SQL*Plus and copy and paste your session.

Regards
Michel
Re: Raise_Application_Error [message #397035 is a reply to message #397029] Wed, 08 April 2009 12:27 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
What is this funny "&D" thing that you seem to use all the time by the way, are you trying to write part of the code with substitution variables?

Re: Raise_Application_Error [message #397113 is a reply to message #397024] Thu, 09 April 2009 01:16 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
MR[T
wrote on Wed, 08 April 2009 19:09]In both Program Exception of too_many_rows is used ,but one is working with RAISE_APPLICATION_ERROR AND another is working with DBMS_OUTPUT.PUT_LINE .
Please tell me the basic difference between these two KEYWORDS .

Step one: form yourself a hyothesis:
Based on merely the name of the two, what would YOU think is the difference?
Both names are pretty self-explanatory.
Previous Topic: Record Generation
Next Topic: dbms_xmldom.writetofile(DOMDocument,path)
Goto Forum:
  


Current Time: Sun Dec 11 00:26:58 CST 2016

Total time taken to generate the page: 0.21747 seconds