[freetds] Empty string in db-lib
damoxc at gmail.com
Mon May 10 10:35:24 EDT 2010
On 10 May 2010 15:01, Jackson, Craig (Gale) <Craig.Jackson at cengage.com> wrote:
> I believe that the real issue is in the protocol spec and the databases.
> Sybase, in particular, does not distinguish zero-length strings from NULLs in the database.
> Is there an expectation that they would be stored differently?
> -----Original Message-----
> From: freetds-bounces at lists.ibiblio.org [mailto:freetds-bounces at lists.ibiblio.org] On Behalf Of Damien Churchill
> Sent: Monday, May 10, 2010 6:21 AM
> To: avictor.za at gmail.com
> Cc: FreeTDS Development Group
> Subject: Re: [freetds] Empty string in db-lib
> On 10 May 2010 08:22, avictor.za at gmail.com <avictor.za at gmail.com> wrote:
>>>>> Is it possible to send an empty string as a parameter when making rpc
>>>>> calls? All my efforts so far seem to result in the parameter ending up
>>>>> being NULL when doing a trace on the server!
>>>> It works. Cf. src/dblib/unittests/rpc.c.
>>>> According to Sybase, "If the value of the RPC parameter is NULL, pass
>>>> datalen as 0, even if type is a fixed-length datatype." That's what the
>>>> unit test does, and the server recognizes them as NULL.
>>> >From that it looks like it isn't possible to just send an empty string
>>> '' which of course is different to NULL? Is this a limitation of
>>> db-lib or the TDS protocol?
>> We had the same issue with CTLib.
>> Search mailing-list archive for "FreeTDS always setting empty
>> VARCHAR's to NULL" (24 May 2009).
>> A similar fix might be required for dblib.
> Ahh excellent, I will have to investigate this a bit further once I
> have my machine back up and running! Thanks for pointing me in the
> right direction!
I believe the issue will be when passing the parameters to a stored
procedure they (being my co-workers) were checking for the varchar to
be "", so just required fixing of the SQL in the sprocs. It was more a
curiosity thing since you can have empty strings in MSSQL so wondered
if it was a limitation of FreeTDS or the TDS protocol!
More information about the FreeTDS