freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- 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:Yes, thank you. dbconvert() works as expected, I can also convert to SQLCHAR (to not lose precision) ;-)
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, I found tds_numeric_to_string() in numeric.c where I can see how it works.
If you want the sausage-factory details, cf. tds_convert() source code.
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
-
[freetds] db-lib DBNUMERIC structure,
LacaK, 09/12/2011
-
Re: [freetds] db-lib DBNUMERIC structure,
jklowden, 09/12/2011
- Re: [freetds] db-lib DBNUMERIC structure, LacaK, 09/13/2011
-
Re: [freetds] db-lib DBNUMERIC structure,
jklowden, 09/12/2011
Archive powered by MHonArc 2.6.24.