Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> how to tell the difference between NULL and an empty string?
Here's an excerpt of the Oracle documentation
"Oracle currently treats a character value with a length of zero as null.
However, this
may not continue to be true in future releases, and Oracle recommends that
you do not treat empty strings the same as NULLs"
How can I not treat empty strings the same as NULLs when the only way to select only those records with zero-length string is by checking if they're null :
Select * from testTable where myString is null ; --> fetch rows where myString = ''
Select * from testTable Where myString = '' ; --> fetch nothing
Select * from testTable where trim (myString) = '' ; --> fetch nothing
Select * from testTable where myString is not null ; --> fetch rows where mystring <> ''
Select * from testTable where mystring <> '' ; --> fetch nothing
Select * from testTable where myString <> '' and myString is not null
--> fetch nothing, but should fetch
rows with non-zero-length strings
So, apparently, there's no way to tell the difference between '' and null, but Oracle recommends that you consider it different, but how?
thanks
Patrick Received on Mon Mar 13 2000 - 14:18:13 CST
![]() |
![]() |