Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Why Doesn't This Simple PL/SQL Code Work?

Re: Why Doesn't This Simple PL/SQL Code Work?

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Tue, 11 Apr 2006 20:45:19 +0200
Message-ID: <443bf93f$0$2077$626a54ce@news.free.fr>

"DBA9999" <cdavis10717_at_comcast.net> a écrit dans le message de news: 1144780180.375527.204110_at_j33g2000cwa.googlegroups.com...
| OK, I give up, I can not make this simple pl/sql code block give me a
| message when no data is returned from a table.
|
| I correctly get the output line when a row is returned, but not when no
| row is returned.
|
| What am I doing wrong, please?
|
| Thanks so much.
|
| C
|
|
|
| REM ==================================================
| REM
| REM confirm that THIS_HOST is Configured
| REM
| REM ==================================================
|
| set serveroutput on
|
| 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'
| ;
|
| begin
| dbms_output.put_line('HOST VALUE IS '||this_host);
| end;
|
| if
| this_host is NULL
| then
| begin
| dbms_output.put_line('HOST NOT CONFIGURED....EXITTING;');
| end;
| else
| begin
| dbms_output.put_line('HOST '||this_host||' CONFIGURED....EXITTING;');
| end;
|
| end if;
|
| exception
| when case_not_found then
| this_host := NULL;
| when others then rollback;
|
| end;
|
| .
| run;
|

No row -> error NO_DATA_FOUND -> OTHERS -> does nothing

OTHERS -> always add "RAISE;" else you can't know the error reason.

Regards
Michel Cadot Received on Tue Apr 11 2006 - 13:45:19 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US