Skip to Content.
Sympa Menu

freetds - [freetds] Datatype conversion

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "P. Sankar" <SankarP AT catsglobal.co.in>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] Datatype conversion
  • Date: Wed, 19 Nov 2003 12:15:38 +0530

Hi,

I am introducing myself as software engineer and working on

data warehousing tool.

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

First, I converted the money datatype to decimal. Again I converted

from decimal into character.

The pSrc is the

char *pSrc;

dbconvert(dbproc, SYBMONEY, pSrc, sizeof(DBMONEY), SYBDECIMAL, (unsigned
char *)&decTemp, sizeof(DBDECIMAL));
dbconvert(dbproc, SYBDECIMAL, (unsigned char *const)&decTemp,
sizeof(DBDECIMAL), SYBCHAR, tmpstr, -1);


After conversion, the above values loses its scale value by 1. Before the
first conversion, I have

set the precision and scale value length to 38 and 5.

For example, after conversion I am getting the result as follows.

123456789123456.8700
123456789123456.9800
123456789123456.9700


But, I have tried the same conversion using the following query in SQL
Server Query Analyzer.

SELECT CONVERT(decimal(38,4) , 123456789123456.8800)

I am getting the correct answer for the above query. Also, I have converted
the converted value

to character.

SELECT CONVERT(CHAR(50),CONVERT(decimal(38,4) , 123456789123456.8800))

In this case, there is no loss in scale value.


Could you please suggest the solution for this problem.


Rgds,

Sankar.P.





Archive powered by MHonArc 2.6.24.

Top of Page