Skip to Content.
Sympa Menu

freetds - Re: [freetds] Records containing DATE data types fail to bulk load with freebcp

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: freetds AT lists.ibiblio.org
  • Subject: Re: [freetds] Records containing DATE data types fail to bulk load with freebcp
  • Date: Tue, 14 Jan 2014 23:40:34 -0500

On Mon, 13 Jan 2014 11:16:25 -0500
Stephen Marshall <smarshall AT kayak.com> wrote:

> Frankly, after isolating this problem to these byte codes, I thought
> fixing this would be easy. However, there are a number of
> transformations and special cases in the data conversion code from
> the tds and dblib libraries. After inserting a special case to set
> type to 49 (SYBDATE) and length to 4 if usertype is 37, freebcp
> failed with this error, caused by a failure of the tds_convert
> function: Requested data conversion does not exist
>
> It seems additional logic, perhaps in or around tds_convert() is
> needed to support the SYBDATE data type. I've spent about day trying
> to find the right place to insert this logic, but, at this point, I
> am chasing my tail. If someone on the list has insight into how to
> add support for a new data type, I'd appreciate some direction.

You may find the work Frediano has done with ODBC for TDS 7.3 types is
useful to you.

Start with tds_willconvert(), some of which is generated from a perl
script. You'll also need a struct to hold your DATE components in
wire format if it doesn't fit something we already have. Then for
tds_convert() you'll need

1. A function that accepts a DATE and returns at least VARCHAR,
whatever is commensurate with tds_willconvert().

2. For each type that can be converted to DATE, add the logic to the
switch in the function that accepts that type in convert.c.

3. In db-lib, you'll need SYBDATE and the same struct that libtds uses
fo the wire format. You want to extend dbdatecrack(), too, lest you
start parsing strings instead when you want to know the month in your
application.

Conversion should be symmetrical: if A -> B then B -> A.

Now you have a DATE structure and the functionality to convert between
DATE and strings. The changes to freebcp fall out pretty easily, as
you've already seen.

HTH.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page