CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Steve Hebert's Development Blog

Steve's Blog - From .Net to dotMath and everything in between.

Befuddled Tech - Sybase strings and nulls

We ran into a problem with our Sybase servers and how they store strings.  It turns out that when you store an empty string,  Sybase always returns a single space.  Using the following insert statement (quoted string with no space).

insert into customer (lastname) values ('')

The result is lastname == '{space}'

I didn't think any commercial database still implemented it this way. 

Note to Sybase - empty string and null are two distinctly different values.









Comments

Jeff Lewis said:

Oracle is no better...
# June 20, 2006 1:48 PM

Ron said:

I don't see where Sybase inferred a null anywhere.
As I understand it, it 'normalizes' strings of zero or
more blanks such that trailing/'invisible' blanks are irrelevent.
This is not meant to be a technically correct answer,
just how I see it.
# June 20, 2006 5:16 PM

Josh said:

What were you expecting to happen? Did you want lastname to be null, or an empty string?

Oracle is still screwy too, in that it treats an empty string as null.
# June 21, 2006 9:59 AM
Check out Devlicio.us!

Our Sponsors

Free Tech Publications