Skip to Content.
Sympa Menu

freetds - RE: Losing last character of TEXT fields

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <ThompBil AT exchange.uk.ml.com>
  • To: "'TDS Development Group'" <freetds AT franklin.oit.unc.edu>
  • Subject: RE: Losing last character of TEXT fields
  • Date: Wed, 10 Jul 2002 13:38:16 +0100

Freddy,

here's a lttle .txt document I'm working with, which describes the relvant
aspects of dblib dbconvert() and ctlib cs_convert()

As far as dbconvert goes, I (hope I) implemented the destlen functionality
in tds_convert_any().
As you may be aware though, not all the tds_convert_x functions in convert.c
use the tds_convert_any function.
This includes tds_convert_text(), hence (in my view) some of the problems
that have occurred - the handling of return data should be in one place
only!

<<destlen.txt>>
Bill



dbconvert precis (Sybase)
-------------------------

destlen - The length, in bytes, of the destination variable.
destlen is ignored for fixed-length datatypes.
For a SYBCHAR, SYBBOUNDARY or SYBSENSITIVITY destination,
the value of destlen must be the total length of the destination
buffer space.

The following table describes special values for destlen:

Special values for destlen (dbconvert)

destlen Applicable To Meaning

-1 SYBCHAR, SYBBOUNDARY, There is sufficient space available.
SYBSENSITIVITY The string will be trimmed of
trailing blanks
and given a terminating null.

-2 SYBCHAR There is sufficient space available.
The string will not be trimmed of
trailing blanks,
but will be given a terminating null.

Notes: SYBBOUNDARY and SYBSENSITIVITY destinations are always null-terminated.

dbconvert precis (Microsoft)
----------------------------
destlen - The length, in bytes, of the destination variable.
This length is used for the following desttype data type tokens:

SQLCHAR, SQLVARCHAR, SQLTEXT
SQLBINARY, SQLVARBINARY, SQLIMAGE
SQLINTN, SQLFLTN, SQLMONEYN, SQLDATETIMN

The destlen is ignored for all fixed-length, non-NULL data types.

When dest points to a DBCHAR string or a DBBINARY array,
the value of destlen must be the total length of the destination
buffer space,
or -1 to indicate that there is sufficient space available.
Note that when dest points to a DBCHAR string,
a destlen of -1 causes the character string to be given a
terminating null.



cs_convert precis
-----------------

destfmt - A pointer to a CS_DATAFMT structure describing the destination data
format.
The following table lists the fields in *destfmt that are used.

Field Name Set It To
---------- ---------

datatype A type constant representing the desired destination datatype
(CS_CHAR_TYPE, CS_BINARY_TYPE, and so on).

maxlength The length of the destdata buffer.

locale A pointer to a CS_LOCALE structure containing localization
values for the destination data, or NULL to use localization values from
*context.

format A bit mask of the following symbols:

For character and text destinations only,
use CS_FMT_NULLTERM to null-terminate the data,
or CS_FMT_PADBLANK to pad to the full length of the variable
with spaces.
For character, binary, text, and image destinations,
use CS_FMT_PADNULL to pad to the full length of the variable
with nulls.
When converting from a character source to a character
destination,
For any type of destination, use CS_FMT_UNUSED if no format
information is being provided.

my notes: obviously FMT_PADBLANK and FMT_PADNULL should be mutually
exclusive, although their
implementaion as bitmaps means it is possible to specify
both(!)





Archive powered by MHonArc 2.6.24.

Top of Page