Skip to Content.
Sympa Menu

freetds - RE: [freetds] datatype conversion

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "ZIGLIO Frediano" <Frediano.Ziglio AT vodafone.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] datatype conversion
  • Date: Tue, 18 Nov 2003 15:10:12 +0100

>
> 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
>

Which sql server (Microsoft or Sybase?) type are server columns ?

> First, I converted the money datatype to decimal. Again I converted
>
> from decimal into character.
>
> The pSrc is the
>
> char *pSrc;
>

Where does pSrc come?

> 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)
>

This query do not convert number to money so it's not the same thing.

> 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.
>

bye
freddy77




Archive powered by MHonArc 2.6.24.

Top of Page