Skip to Content.
Sympa Menu

freetds - Re: [freetds] Prepared Statement is losing the seconds valu

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "ZIGLIO, Frediano, VF-IT" <Frediano.Ziglio AT vodafone.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Prepared Statement is losing the seconds valu
  • Date: Fri, 22 Dec 2006 09:34:50 +0100

>
> Here is a relatively small program that illustrates the problem. It
> attempts to set a DATETIME field to "2006-12-21 05:34:12.000" but the
> actual value that goes into the database is "2006-12-21 05:34:00.000".
>

... program omissis ...

Now I understand the problem (and I found the solution!).

When you prepare a query without passing parameters libTDS prepare query
using a default varchar(80). When you execute the query you can pass
different types (like DATETIME you used). It seems that mssql do a
strange conversion loosing precision. The solution (see fix.diff) is to
prepare query using correct parameters type so mssql use all precision.
Note that the execute (not the prepare) produce same data to server,
server reply the same way but data loose precision.
I know that our ODBC (and MS one too) automatically prepare again the
query when you change type.

Frediano

Attachment: fix.diff
Description: fix.diff

Attachment: xxx0.c
Description: xxx0.c




Archive powered by MHonArc 2.6.24.

Top of Page