[freetds] MONEY fields

Daniel Kasak dkasak at nusconsulting.com.au
Wed Mar 28 19:22:17 EST 2007


Greetings.

I've just hit a bug which I'm pretty sure I've encountered before. I 
even think I posted a message about it, but now I can't find it in the 
archives, so maybe I'm mistaken.

Anyway, it seems impossible to update MONEY fields in SQL Server 7 from 
FreeTDS. I'm using DBD::ODBC ==> UnixODBC ==> FreeTDS ( latest versions 
of each ). I'm using a statement with placeholders ( for ALL values I'm 
updating, including the 2 fields it's complaining about below ), and 
when I try to prepare() it, I get:

[unixODBC][FreeTDS][SQL Server]Statement(s) could not be prepared. 
(SQL-42000)
[unixODBC][FreeTDS][SQL Server]Disallowed implicit conversion from data 
type varchar to data type money, table 'NUSsql.dbo.Recommendations', 
column 'Estimate'. Use the CONVERT function to run this query. (SQL-42000)
[unixODBC][FreeTDS][SQL Server]Disallowed implicit conversion from data 
type varchar to data type money, table 'NUSsql.dbo.Recommendations', 
column 'ConfirmAmount'. Use the CONVERT function to run this query. 
(SQL-42000)(DBD: st_prepare/SQLPrepare err=-1) at 
/usr/lib/perl5/site_perl/5.8.8/Gtk2/Ex/DBI.pm line 1267.

I'm pretty sure last time I found this, I convered my fields to DECIMAL, 
and everything worked. But for completeness, it would be good if MONEY 
types were supported.

I can't ( easily ) use the convert function as suggested here, as I'm 
using a generic recordset handler to construct my SQL statements, and it 
doesn't know about SQL Server's field types and CONVERT requirements 
either. Admittedly, I could hack something into it which inspected SQL 
Server field types somehow and automatically wrapped stuff in CONVERT, 
but I'd prefer not to add such dodgy hacks unless I really have to. Is 
there a better way?

-- 
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak at nusconsulting.com.au
website: http://www.nusconsulting.com.au


More information about the FreeTDS mailing list