Home » SQL & PL/SQL » SQL & PL/SQL » help
help [message #233686] Fri, 27 April 2007 03:11 Go to next message
marisa
Messages: 4
Registered: April 2007
Junior Member
i`m preparing on Pl/SQL please help me with this code

DECLARE
NO_DATA_FOUND EXCEPTION;
BEGIN
RAISE NO_DATA_FOUND;
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line(‘Error message here’);
END;
Re: help [message #233690 is a reply to message #233686] Fri, 27 April 2007 03:14 Go to previous messageGo to next message
tahpush
Messages: 961
Registered: August 2006
Location: Stockholm/Sweden
Senior Member

You need to be more specifik

is it the Structure ?

Quote:
DECLARE
Declarative section: variables, types, and local subprograms.

BEGIN
Executable section: procedural and SQL statements go here.
This is the only section of the block that is required.

EXCEPTION

Exception handling section: error handling statements go here.
END;
Re: help [message #233697 is a reply to message #233690] Fri, 27 April 2007 03:21 Go to previous messageGo to next message
marisa
Messages: 4
Registered: April 2007
Junior Member
it is a Program...
i Would like to Know the Out put of the program if possible little Explanation

Re: help [message #233698 is a reply to message #233697] Fri, 27 April 2007 03:23 Go to previous messageGo to next message
Michel Cadot
Messages: 64130
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> DECLARE
  2  NO_DATA_FOUND EXCEPTION;
  3  BEGIN
  4  RAISE NO_DATA_FOUND;
  5  EXCEPTION
  6  WHEN NO_DATA_FOUND THEN
  7  dbms_output.put_line('Error message here');
  8  END;
  9  /
Error message here

PL/SQL procedure successfully completed.

Regards
Michel
Re: help [message #233779 is a reply to message #233698] Fri, 27 April 2007 07:54 Go to previous messageGo to next message
Littlefoot
Messages: 20897
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You have declared an exception and name it NO_DATA_FOUND.

First statement raises this exception (RAISE NO_DATA_FOUND) which leads you to the exception handler section (it starts with the EXCEPTION keyword).

It says that whenever NO_DATA_FOUND exception is raised, do what follows the THEN keyword: in your case, you chose to put a message 'Error message here' to the screen (if DBMS_OUTPUT has been enabled).

Basically, such an exception - which is predefined - doesn't need to be declared. If you, for example, had a code which contained a SELECT ... INTO statement which found nothing, it would raise NO_DATA_FOUND anyway; you'd just have to make sure that you handled this exception properly (by having an exception handler, as in this example).

There are also several other predefined exceptions, such as TOO-MANY-ROWS, INVALID_NUMBER, DUP_VAL_ON_INDEX etc.
Re: help [message #233789 is a reply to message #233686] Fri, 27 April 2007 08:26 Go to previous messageGo to next message
michael_bialik
Messages: 611
Registered: July 2006
Senior Member
Issue:

SET SERVEROUTPUT ON SIZE 999999

before executing PL/SQL block

Michael

[Updated on: Fri, 27 April 2007 08:29]

Report message to a moderator

Re: help [message #233874 is a reply to message #233789] Fri, 27 April 2007 17:27 Go to previous messageGo to next message
Littlefoot
Messages: 20897
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
What is the advantage of setting output buffer size to 999.999 instead of, let's say, 1.000.000?
Re: help [message #233878 is a reply to message #233686] Fri, 27 April 2007 17:44 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
>What is the advantage of setting output buffer size to 999.999 instead of, let's say, 1.000.000?
One less key stroke.
Re: help [message #233981 is a reply to message #233878] Sat, 28 April 2007 12:52 Go to previous messageGo to next message
Littlefoot
Messages: 20897
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Oh, so we spend less energy and help preventing global warming.
Re: help [message #234033 is a reply to message #233686] Sun, 29 April 2007 02:32 Go to previous messageGo to next message
michael_bialik
Messages: 611
Registered: July 2006
Senior Member
I'm lazy - so it's easier for me to press 6 times 9.

Michael.
Re: help [message #234054 is a reply to message #234033] Sun, 29 April 2007 04:20 Go to previous message
Littlefoot
Messages: 20897
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
And I was just kidding!
Previous Topic: Do you think select statement on the matererialed view is faster than on the table?
Next Topic: Help
Goto Forum:
  


Current Time: Wed Dec 07 10:26:47 CST 2016

Total time taken to generate the page: 0.11781 seconds