[freetds] Prepared Statement is losing the seconds valu
joseph.blough at thomson.com
joseph.blough at thomson.com
Fri Dec 22 06:05:29 EST 2006
Thank you! That fixed the problem perfectly.
-----Original Message-----
From: freetds-bounces at lists.ibiblio.org
[mailto:freetds-bounces at lists.ibiblio.org] On Behalf Of ZIGLIO,
Frediano, VF-IT
Sent: Friday, December 22, 2006 3:35 AM
To: FreeTDS Development Group
Subject: Re: [freetds] Prepared Statement is losing the seconds valu
>
> 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
More information about the FreeTDS
mailing list