Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

It seems Sybase converts the empty string to single space string

2 posts in General Discussion Last posting was on 2002-07-24 15:34:00.0Z
Siddappa Posted on 2002-07-24 13:35:37.0Z
Message-ID: <>
Date: Wed, 24 Jul 2002 19:05:37 +0530
From: Siddappa <>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0rc2) Gecko/20020618 Netscape/7.0b1
X-Accept-Language: en-us, en
MIME-Version: 1.0
Subject: It seems Sybase converts the empty string to single space string
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Newsgroups: ianywhere.public.general
Lines: 41
Path: forums-1-dub!!
Xref: forums-1-dub ianywhere.public.general:728
Article PK: 3236


I am using Sybase SQL Anywhere studio(version 7.0.2). I am facing
some strange problem(explained below) .

I have one table like;

create table CUTSOMER (
ID integer not null,
NAME varchar(80) null,
primary key(ID)

In my application using JDBC, I am inserting customer record with
the ID=1 and NAME="" (an empty string with length 0). I could see
this record getting stored in the db through 'dbisql' GUI.

When I query( "select * from CUSTOMER where ID=1" )this record
using JDBC, I get the expected customer record in the result set.
In the result set, I get the column ID value as 1, but the column
NAME value as single space string( a string with length 1) instead
of empty string(which I inserted).

I have the following questions regarding this problem;

1. I this a bug in Sybase database or the Sybase Driver?
( I am using com.sybase.jdbc2.jdbc.SybDriver)

2. How the empty string ("") is getting stored/retrievd in/from
( I heard Oracle databse will convert the empty string to null
string before storing it into database ).

Please let me know if any of you have come across this problem.
For the workaround, Where ever I have an empty string before storing
it into DB, I am converting the empty string value to null string.
This workaround works fine but I would like to know what's the actual

Any help would be appreciated...

Thanks in advance.

Rick Blythe Posted on 2002-07-24 15:34:00.0Z
From: "Rick Blythe" <>
References: <>
Subject: Re: It seems Sybase converts the empty string to single space string
Date: Wed, 24 Jul 2002 11:34:00 -0400
Lines: 16
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <>
Newsgroups: ianywhere.public.general
Path: forums-1-dub!!
Xref: forums-1-dub ianywhere.public.general:727
Article PK: 3234

TDS (i.e. Open Client and JDBC) always assume they are connecting to an ASE
database, or the equivalent. When ASA detects a TDS connection, it emulates
ASE to allow the connection. In ASE, all strings a padded with spaces for
comparison purposes. I.e. 'blah' is treated as equal to 'blah '. Thus, an
empty string does not have the same meaning for ASE as for ASA.

A NULL character is stored in the database as the hex value 0x00 and an
empty string is stored as 0x20. The only way for TDS to distinguish between
an empty string and a NULL is to assign a length of 1 to the empty string.

You will need to write your program to take this behavior into account, or
else generate the string lengths from within the engine, rather than at the
connection level.