[freetds] dbbind funny

Thompson, Bill D (London) bill_d_thompson at ml.com
Thu Jun 10 11:08:53 EDT 2004


I was just fixing the code to dbbind/dbnextrow/etc. for the dbnullbind
indicators issue.

On my first test, Many of the unittests failed :-)

I'd cleared up the code a bit, added support for VARYCHARBIND as well.

It turns out many of the unittests use -1 as a "varlen" parameter to

t0001.c:        if (SUCCEED != dbbind(dbproc, 2, STRINGBIND, -1, (BYTE *)
teststr)) {

My cleared up code didn't like this, as it doesn't appear to be in the man
pages for either Sybase or MS, e.g. Sybase:


The length of the program variable in bytes.

For values of vartype that represent a fixed-length type, such as MONEYBIND
or FLT8BIND, this length is ignored.

For char, text, binary, and image types, varlen must describe the total
length of the available destination buffer space, including any space that
may be required for special terminating bytes, such as a null terminator. If
varlen is 0, the total number of bytes available will be copied into the
program variable. (For char and binary server data, the total number of
bytes available is equal to the defined length of the database column,
including any blank padding. For varchar, varbinary, text, and image data,
the total number of bytes available is equal to the actual data contained in
the column.) Therefore, if you are sure that your program variable is large
enough to handle the results, you can just set varlen to 0.

any ideas on this ?


Bill Thompson
GMI Technology
Merrill Lynch Europe

+44 207 995 8307

For very important information relating to this e-mail please click on this
link:  http://www.ml.com/legal_info.htm


If you are not an intended recipient of this e-mail, please notify
the sender, delete it and do not read, act upon, print, disclose,
copy, retain or redistribute it.

Click here for important additional terms relating to this e-mail.


More information about the FreeTDS mailing list