[Dbix-class] mssql 'convert' function in DBIx::Class

Michael Higgins listinfo at banfieldgroup.com
Wed Aug 8 18:06:01 GMT 2007


Hello --

I'm working with a SQL Server 2000 database. One of the columns is of type 'money'. 

I've come to understand the issue I have originates with DBI placeholders which cause an error about not automagically converting the datatype. (Changing the datatype isn't an option, something to do with MSAccess.) 

The same problem exists with both DBD::ODBC and DBD::Sybase. I'm using FreeTDS and unixODBC to connect to SQL Server.

Anyway, running the query with no placeholder works fine, but then the query has to be prepared each time... And, of course, all DBIx-Class functions fail when I have to query this 'money' field, because it uses placeholders.

So, I've discoverd this hack to the SQL, which works:
                                            |||||||||||||||||||||||||||
my $q = q/select * from DATA where convert(float, "Total Cost")=? order by "Invoice #"/;
my $sth=$dbh->prepare($q);
$sth->execute(230.03);

My question is, where would I indicate that 'convert()' stuff in DBIx::Class setup for that accessor? Is this possible? I know I can get the sth($q) from DBIC, but I think that leaves me without magic accessors, right?

Any clue appreciated, I'm obviously lacking a bit. :-/

Cheers,

-- 
Michael Higgins <listinfo at banfieldgroup.com>



More information about the DBIx-Class mailing list