Skip to Content.
Sympa Menu

freetds - Re: [freetds] Empty VARCHAR parameters converted to NULL

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Empty VARCHAR parameters converted to NULL
  • Date: Tue, 19 Jan 2016 10:52:15 +0000

2016-01-16 1:41 GMT+00:00 Joshua Lang <joshua.h.lang AT gmail.com>:
> In the latest version of FreeTDS-dblib (0.95.79) I'm passing rpc VARCHAR
> parameters of 0 length, but non-NULL (empty strings). FreeTDS seems to turn
> these into NULL values before passing them on to SQL Server. From what I've
> read, it seems as if older databases didn't support passing empty strings,
> but newer ones do? (i.e. TDS 7.0+ do support empty strings).
>
> It seems as this is a known issue, but I was wondering if it is possible to
> fix it for the newer versions of SQL server? E.g. in dbrpcparam() passing a
> non-NULL pointer to the 'value' parameter and a 0 to 'datalen' would
> indicate an empty string is desired if possible.
>
> Thoughts?


The main problem is not libTDS (the code library) but dbrpcparam
specification.
datalen < 0 is invalid for variable fields (like VARCHAR) and 0 is used for
NULL
value (no matter the data pointer). But looks like your suggestion
(not NULL value
and 0 datalen) could be a good choice.
Not sure however if this could work with all types and server versions
(for instance
0 size TEXT).
We can do it but I'm not thinking about backporting it to 0.95.

Frediano




Archive powered by MHonArc 2.6.24.

Top of Page