Home » SQL & PL/SQL » SQL & PL/SQL » Exception handling (Oracle 9)
Exception handling [message #377253] Mon, 22 December 2008 02:49 Go to next message
shaksing
Messages: 115
Registered: November 2008
Senior Member
I want to raise an exception for example - ERROR_COUNT_EXCEPTION , when there is a error in counting the records from the table (in a select query). I already have a NO_DATA_FOUND exception. But i dont want my code to use no data found in all the conditions like the above one.Please suggest me the possible ways.

Regards
Shaksing
Re: Exception handling [message #377256 is a reply to message #377253] Mon, 22 December 2008 02:54 Go to previous messageGo to next message
Frank Naude
Messages: 4502
Registered: April 1998
Senior Member
You can always define ERROR_COUNT_EXCEPTION as an exception:

DECLARE
  PRAGMA EXCEPTION_INIT(error_count_exception, ...
...
EXCEPTION
  WHEN error_count_exception THEN ...
Re: Exception handling [message #377264 is a reply to message #377253] Mon, 22 December 2008 03:07 Go to previous messageGo to next message
shaksing
Messages: 115
Registered: November 2008
Senior Member
I declared in the procedure like that
PRAGMA EXCEPTION_INIT(error_count_exception);
under IS after create and replace procedure_name.
But it is giving error .

PLS-00128 Illegal number of arguments for pragma string
.

Another small thing , where we use IS and where we use DECLARE ? Please tell me the difference too.

Re: Exception handling [message #377265 is a reply to message #377264] Mon, 22 December 2008 03:12 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
Do not blindly use code without first researching it and finding out how to use it. Go to the documentation look up the syntax for pragma exception_init before you attemt to actually use it in your code.

[Updated on: Mon, 22 December 2008 03:38]

Report message to a moderator

Re: Exception handling [message #377268 is a reply to message #377253] Mon, 22 December 2008 03:16 Go to previous messageGo to next message
shaksing
Messages: 115
Registered: November 2008
Senior Member
Hi pablolee

The link is not opening.
Re: Exception handling [message #377269 is a reply to message #377253] Mon, 22 December 2008 03:21 Go to previous messageGo to next message
trivendra
Messages: 208
Registered: October 2007
Location: Noida, India
Senior Member
Try this

http://www.stanford.edu/dept/itss/docs/oracle/10g/appdev.101/b10807/07_errs.htm


Thanks
Trivendra
Re: Exception handling [message #377270 is a reply to message #377253] Mon, 22 December 2008 03:22 Go to previous messageGo to next message
shaksing
Messages: 115
Registered: November 2008
Senior Member
Ok i am able to work with pragma .

But what is the difference between IS and Declare.
Re: Exception handling [message #377271 is a reply to message #377270] Mon, 22 December 2008 03:24 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
IS/AS is used as part of a procedure/function/package

DECLARE is used in Anonymous Pl/Sql Blocks
Re: Exception handling [message #377276 is a reply to message #377268] Mon, 22 December 2008 03:38 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
Sorry about the wrong link, fixed now
Re: Exception handling [message #377281 is a reply to message #377253] Mon, 22 December 2008 03:51 Go to previous message
shaksing
Messages: 115
Registered: November 2008
Senior Member
Thanks a lot to all.
Previous Topic: How to get the usage details of column or table ?
Next Topic: UPDATE is really a DELETE followed by an INSERT
Goto Forum:
  


Current Time: Wed Dec 07 08:50:51 CST 2016

Total time taken to generate the page: 0.12241 seconds