Skip to Content.
Sympa Menu

freetds - [freetds] bcp CHAR behavior

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT schemamania.org>
  • To: TDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: [freetds] bcp CHAR behavior
  • Date: Thu, 15 Apr 2004 22:41:11 -0400

src/dblib/bcp.c:1107:

if (desttype == SYBVARCHAR) {
bcpcol->data_size =
_bcp_rtrim_varchar((char *) bcpcol->data, converted_data_size);
} else {
bcpcol->data_size = converted_data_size;
}

I ran across what might be a little bug in the above code today. I was
loading a tab-delimited file; column two in the table was a char(2).
freebcp was complaining. (The actual message was bogus iirc, something
about inserting a NULL into a non-null column.) The real problem was that
the field contained a trailing blank:

'AR '

You can imagine it took a bit of hunting, because the error file didn't
exactly highlight the space before the tab.

Microsoft's bcp.exe loaded the file fine, after I DOSified it. So they
trim the trailing blank for char & varchar fields. Maybe for everything?


I wonder how Sybase's utility behaves. I think I may change the above to
call _bcp_rtrim_varchar() every time.

Any insights?

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page