Skip to Content.
Sympa Menu

freetds - Re: [freetds] MONEY type support??

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Sokol, Ryan - 244" <ryans AT HA.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] MONEY type support??
  • Date: Tue, 19 Dec 2006 08:11:19 -0600

Funny thing is I don't see this problem with PHP & FreeTDS when I'm
connecting via db-lib and the mssql_* commands from PHP. I only see
this is ODBC mode.

Thanks for the info. I was hoping for a more global/one place fix. Oh
well.

-----Original Message-----
From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of James K. Lowden
Sent: Monday, December 18, 2006 10:02 AM
To: FreeTDS Development Group
Subject: Re: [freetds] MONEY type support??

Sokol, Ryan - 244 wrote:
> Anyway to NOT have the client round it?

We know now that's basically a PHP question, because PHP is the client
(as
far as FreeTDS is concerned) and PHP converts most datatypes to strings.

Because PHP (I assume) uses the db-lib dbconvert() function, it gets a
result rounded to two places.

Answer is not to have your query return MONEY columns when you don't
want
this behavior. I suggest "CAST(mycol to NUMERIC(p,s)) as mycol",
substituting of course your preferred values for precision and scale.
>From the docs:

"Monetary data values from -2^63 (-922,337,203,685,477.5808)
through
2^63 - 1 (+922,337,203,685,477.5807), with accuracy to a ten-thousandth
of
a monetary unit. Storage size is 8 bytes."

That looks like numeric(20,4) to me. You can also use the T-SQL CONVERT
function, passing a style of '2' i.e.:

convert(varchar(22), mycol, 2) as mycol

That should do the trick. Cf.
http://msdn2.microsoft.com/en-us/ms187928.aspx for details.

HTH.

--jkl

> -----Original Message-----
> From: freetds-bounces AT lists.ibiblio.org
> [mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of
> michael.peppler AT bnpparibas.com
> Sent: Monday, December 18, 2006 12:51 AM
> To: freetds AT lists.ibiblio.org
> Subject: Re: [freetds] MONEY type support??
>
> Actually, MONEY is fixed point, with 4 decimal places. The client
almost
>
> always rounds this to two decimal places, though.
_______________________________________________
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