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: Length of empty string?

Re: Length of empty string?

From: Lothar Armbrüster <lothar.armbruester_at_rheingau.netsurf.de>
Date: 02 May 98 14:03:27 +0100
Message-ID: <895.426T1399T8433722@rheingau.netsurf.de>


On 01-Mai-98 14:57:06 Roy Smith wrote:

>Why does length() return nothing (instead of the number zero) on an
>zero-length string?

SQL>> select length('xxx') from dual;

>LENGTH('XXX')
>-------------
> 3

SQL>> select length('') from dual;

>LENGTH('')
>----------

SQL>>
>The first query makes sense, but the second one does not. I would have
>expected to get back zero. Instead I'm getting back nothing, or blank,
>or something which isn't zero. I'm confused.

Hello Roy,
I think that's because the empty string is equivalent to null and in Oracle most funktion return null when they are given null arguments. You could circumvent the problem by using

select nvl(length(your_string),0) from dual;

Hope that helps,
Lothar

--

Lothar Armbrüster       | lothar.armbruester_at_rheingau.netsurf.de
Schulstr. 12            | lothar.armbruester_at_t-online.de
D-65375 Oestrich-Winkel |

Received on Sat May 02 1998 - 08:03:27 CDT

Original text of this message

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