Skip to Content.
Sympa Menu

freetds - Re: [freetds] db-lib DBNUMERIC structure

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: LacaK <lacak AT zoznam.sk>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] db-lib DBNUMERIC structure
  • Date: Tue, 13 Sep 2011 07:15:43 +0200

jklowden AT schemamania.org wrote / napĂ­sal(a):
On Mon, Sep 12, 2011 at 01:11:01PM +0200, LacaK wrote:
typedef struct dbnumeric
{
char precision;
char scale;
unsigned char val[MAXNUMLEN];
} DBNUMERIC;

for retrieving exact numeric data.

But I can not find, how to interpret/read "val" array to construct number.

Just to remind you, you could just bind the type to DBFLT4 or DBFLT8 (FLT4BIND or FLT8BIND). Or use dbconvert().
Yes, thank you. dbconvert() works as expected, I can also convert to SQLCHAR (to not lose precision) ;-)


If you want the sausage-factory details, cf. tds_convert() source code.
Yes, I found tds_numeric_to_string() in numeric.c where I can see how it works.
I only wonder why sybase uses variable length array (see tds_numeric_bytes_per_prec) with high significant bytes first (so I must start with high array index and walk down). Microsoft approach seems to me simpler (with low significant bytes first, so I start with index 0 and walk to end of array)

Thanks
-Laco.

--jkl
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds






Archive powered by MHonArc 2.6.24.

Top of Page