Skip to Content.
Sympa Menu

freetds - RE: [freetds] datatype conversion

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: 'FreeTDS Development Group' <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] datatype conversion
  • Date: Tue, 18 Nov 2003 11:01:50 -0500

> From: P. Sankar [mailto:SankarP AT catsglobal.co.in]
> Sent: November 18, 2003 8:25 AM

Welcome, Sankar.

> I have few doubts in datatype conversion using the DB library API
> function dbconvert(). I have tried the following numbers to insert
> into SQL Server database after conversion.
>
> 123456789123456.8800
> 123456789123456.9900
> 123456789123456.9800
...
> dbconvert(dbproc, SYBMONEY, pSrc, sizeof(DBMONEY),
> SYBDECIMAL, (unsigned
> char *)&decTemp, sizeof(DBDECIMAL));
> dbconvert(dbproc, SYBDECIMAL, (unsigned char *const)&decTemp,
> sizeof(DBDECIMAL), SYBCHAR, tmpstr, -1);
...
> For example, after conversion I am getting the result as follows.
>
> 123456789123456.8700
> 123456789123456.9800
> 123456789123456.9700

Pennies! What's a few pennies, these days, between friends?

The place to look is the source code: src/tds/convert.c. I suspect the
money->decimal conversion is likely culprit. See tds_convert_money(), also
src/tds/numeric.c::tds_money_to_string().

I do not think decimal->char is a problem, because money is good to four
decimal places and your data are only two deep.

You might also want to look at src/tds/unittests/convert.c.

A patch would be wonderful, if you can manage it. Short of that, it would
be a great help if you could narrow it down to a function or algorithm.

Thanks for the problem report.

--jkl
-----------------------------------------
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above. If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the original
message. Please note that we do not accept account orders and/or instructions
by e-mail, and therefore will not be responsible for carrying out such orders
and/or instructions.






Archive powered by MHonArc 2.6.24.

Top of Page