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: PL/SQL: handling of empty string (strange)

Re: PL/SQL: handling of empty string (strange)

From: Hermann Maier <benutzer_at_beispiel.at>
Date: Thu, 11 Mar 2004 14:54:52 GMT
Message-ID: <e19426fa271d005e7edda1c9472a40b9@news.teranews.com>


stephan schrieb:
> Hi everybody,
>
> I've got this code-sample here which puzzles me:
>
> declare
> s VARCHAR2(1):='S';
> begin
> dbms_output.put_line(s);
> if s!='' then
> dbms_output.put_line('hoppla');
> else
> dbms_output.put_line('ballaballa');
> end if;
> end;
> /
>
> When run the program enters the else-branch. But why - 'S'!='' must
> certainly be true!?

No because the empty string '' is interpreted as NULL. So if you change your code to

if s is NULL then
...

you know why you receive 'ballaballa'.

Try using if length(s) > 0 instead.

HTH, Hermann Received on Thu Mar 11 2004 - 08:54:52 CST

Original text of this message

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