Skip to Content.
Sympa Menu

freetds - Re: TDS 7.0 and decimals

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Brandon M. Reynolds" <breynolds AT comtime.com>
  • To: 'TDS Development Group' <freetds AT franklin.oit.unc.edu>
  • Subject: Re: TDS 7.0 and decimals
  • Date: Fri, 20 Oct 2000 10:05:47 -0400


Ok, the problem is that my C program is requesting to convert from
SYBDECIMAL
to SYBFLT8. SYBFLT8 is not in the case statement in tds_convert_numeric.
So,
I'm sure there are vastly better/more efficient ways to do this, but this
somewhat cheesy patch does the trick.

--- freetds/src/tds/convert.c Tue Jun 6 00:33:10 2000
+++ freetds.10202000/src/tds/convert.c Fri Oct 20 10:01:10 2000
@@ -396,6 +396,7 @@
unsigned long bignum;
char tmpstr[MAXPRECISION];
int left_len;
+double d;

switch(desttype) {
case SYBCHAR:
@@ -408,6 +409,11 @@
memcpy(dest, src, sizeof(TDS_NUMERIC));
return sizeof(TDS_NUMERIC);
break;
+ case SYBFLT8:
+ tds_numeric_to_string(src,tmpstr);
+ d = atof(tmpstr);
+ memcpy(dest,&d,sizeof(double));
+ break;
default:
return TDS_FAIL;
break;
@@ -700,7 +706,7 @@
return tds_convert_money(srctype,src,
desttype,dest,destlen);
break;
- case SYBNUMERIC:
+ case SYBNUMERIC: case SYBDECIMAL:
return tds_convert_numeric(srctype,(TDS_NUMERIC *)
src,srclen,
desttype,dest,destlen);
break;


Brandon M. Reynolds Ph: (330) 644-3059
Systems Engineer Fax: (330) 644-8110
Commercial Timesharing Inc. Email: bmr AT comtime.com





Archive powered by MHonArc 2.6.24.

Top of Page