Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Why Doesn't This Simple PL/SQL Code Work?
Your exception handler simply rolls back and exits, it doesn't
return to where the exception was raised and continue from
there. You need to move
> dbms_output.put_line('HOST NOT CONFIGURED....EXITTING;');
into the exception handler block. Handle correct exception, too, CASE_NOT_FOUND is not the exception you are expecting.
The code should look like this:
declare
this_host varchar2(25) := NULL; this_nmon_dir varchar2(25); this_temp_dir varchar2(25);
begin
select
host, nmon_dir, temp_dir into this_host, this_nmon_dir, this_temp_dir from nmon.nmon_server_config where host = '&1'
dbms_output.put_line('HOST '||this_host||' CONFIGURED....EXITING;');
exception
when NO_DATA_FOUND then dbms_output.put_line('HOST NOT CONFIGURED....EXITING;'); raise; -- this is to re-throw the exception so that itis not masked by the handler
Hth,
Vladimir M. Zakharychev N-Networks, makers of Dynamic PSP(tm) http://www.dynamicpsp.comReceived on Tue Apr 11 2006 - 13:45:59 CDT