Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: differences between null and empty varchar2
SQL's NULL may be the same as an empty string "" in ORACLE, but the
empty string is not the same as a string containing an ASCII nul (X'00
or "\0" in C style). Since Oracle uses counted strings, the empty string
is truely empty (length is zero). This differs from a string containing
one nul character.
I mention C style because Pro*C programmers may get burned by this. If you assign a string containing the nul ('\0') character to a VARCHAR2 variable in embedded SQL, you can get some wheird results. In SQL "" is empty, but in C "" actually is an array of one character '\0'.
So there is some logic to ORACLE's position/implementation.
In article <37AB07F2.4AB0D3FC_at_dced.state.ak.us>,
Calvin Crumrine <Calvin_Crumrine_at_dced.state.ak.us> wrote:
> I would say that logically null meand no value which is the same as an
empty string
> (''). There's nothing between the quotes, so there's no value. It's
not the same as a
> space (' ') however.
>
> I've never looked at it in hex. is X'00 the same as no value?
>
> Vincent Lemaire wrote:
> >
> > when I create a table with a not null varchar2 field, and as I put
an empty
> > value '' into this field, I get the error '... null inserted...'
> > logically, null and '' should not be the same
> > could someone help me to resolve this very disturbing confusion, so
that I
> > could sleep quiet ?
>
--
Ed Prochak
Magic Interface, Ltd.
ORACLE services
440-498-3702
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Received on Fri Aug 06 1999 - 23:12:29 CDT