Skip to Content.
Sympa Menu

freetds - RE: Still problems with 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: Still problems with text fields?
  • Date: Fri, 26 Jul 2002 14:52:41 +0100


Thanks for all that. Just the evidence I need.
I can see all the characteristics of our old convert code being manifested
here. We just need to fix it.
It also looks to me that the interface is pretty simple. You get what's in
the database, null terminated.

One more test you could run for me, with code running on Win2000, compiled
with .NET C++, accessing SQL2000:

Try this:

SQLCHAR sID[21]
...
SQLBindCol(hstmt, 1, SQL_C_CHAR, sID, 20, &cbzName);

and the database column defined as char(30), and filled up with data to that
length

do you get an error (because you haven't defined a variable big enough to
hold the data)
or does ODBC just truncate the data ?


Bill



> -----Original Message-----
> From: Don Burden [SMTP:donb AT zirmed.com]
> Sent: Friday, July 26, 2002 2:34 PM
> To: TDS Development Group
> Subject: [freetds] RE: Still problems with text fields?
>
> Ok, here's some comparisons:
>
> TEST table:
> row id
> ==== ====
> 1
> 2 1
> 3 12
> 4 123
> 5 12
> 6 1
> 7
>
> First, code running on Win2000, compiled with .NET C++, accessing SQL2000:
> ...
> #define MAXLEN 50
> SQLCHAR sID[51]
> ...
> SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
> SQLExecDirect(hstmt,
> (unsigned char *) "Select id from test",
> SQL_NTS);
> SQLBindCol(hstmt, 1, SQL_C_CHAR, sID, MAXLEN, &cbzName);
> while (SQLFetch(hstmt)!= SQL_NO_DATA ))
> printf("//%s//\n", sID);
> ...
>
> id field was rtrimmed when changing types.
>
> Run with id defined as char(20). Notice padding to 20 chars, not 50.
> // //
> //1 //
> //12 //
> //123 //
> //12 //
> //1 //
> // //
>
> Run with id defined as varchar(20)
> ////
> //1//
> //12//
> //123//
> //12//
> //1//
> ////
>
> Run with id defined as text
> ////
> //1//
> //12//
> //123//
> //12//
> //1//
> ////
>
> Outputs garbage data if length changed from MAXLEN to 0 or -1.
> Returncode=-1 from SQLBindCol if length set to -1.
>
> ====================================================
>
> Next, same code running on Linux, FreeTDS + unixODBC
>
> Run with id defined as char(20) (notice output is 50 chars, not 20)
> // //
> //1 //
> //12 //
> //123 //
> //12 //
> //1 //
> // //
>
> Run with id defined as varchar(20) (Bad last row!)
> ////
> //1 //
> //12 //
> //123 //
> //12 //
> //1 //
> //1 //
>
> Run with id defined as text
> ////
> //1&//
> //12//
> //123@//
> //123@//
> //123@//
> //123@//
>
> Changing length to -1 appears to be the only way to get a non-blank
> filled,
> null terminated string when field defined as varchar(20). (Bad last row
> again!):
> ////
> //1//
> //12//
> //123//
> //12//
> //1//
> //1//
>
>
>
> ---
> You are currently subscribed to freetds as: [thompbil AT exchange.uk.ml.com]
> To unsubscribe, forward this message to
> $subst('Email.Unsub')





Archive powered by MHonArc 2.6.24.

Top of Page