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,
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.
Date: Wed, 24 Jul 2002 19:05:37 +0530
From: Siddappa <email@example.com>
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
Subject: It seems Sybase converts the empty string to single space string
Content-Type: text/plain; charset=us-ascii; format=flowed
NNTP-Posting-Host: sj-natpool-220.cisco.com 188.8.131.52
Xref: forums-1-dub ianywhere.public.general:728
Article PK: 3236
Subject: Re: It seems Sybase converts the empty string to single space string
Date: Wed, 24 Jul 2002 11:34:00 -0400
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
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