[freetds] 'Money' column types need an explicit convert

Daniel Kasak dkasak at nusconsulting.com.au
Mon Aug 14 21:51:51 EDT 2006

James K. Lowden wrote:

> You said it's a "simple update" statement, indicating that somewhere
> you're pointing quotes around a numeric value or storing a number in a
> variable declared as char/varchar.  Stop doing that and you'll be OK.  ;-)
> If you're binding to a character host variable, similar restrictions
> apply.  

OK. I should probably have posted some code as well. Sorry. I'm doing:

sub on_DisputeAmount_clicked {
    my ( $self, $widget, $event ) = @_;
    if ( $event->type ne '2button-press' ) {
    my $amount = dialogs::input_box->new( {
                                            title   => "Dispute Amount",
                                            prompt  => "Enter dispute
    if ( $amount || $amount == 0 ) {
        # Strip dollar signs and commas
        $amount =~ s/[\$|\,]//g;
        my @values = ( $amount, $self->{clientid} );
            "update Clients set DisputeAmount = ? where ID = ?",

The 'dbdo' function is a very light wrapper around:

$sth = $dbh->prepare( $sql );
$sth->execute( $sql, $values );

Being Perl, I suppose it mightn't be accurate to say that $amount is
numeric. It's a scalar anyway. It holds a number and nothing else by the
time it gets to the 'dbdo' function. At least I've always tested it with
numeric data. I'm not concerned if someone enters text where a number
should be - I raise a suitable warning in this case ( in 'dbdo' ).

Anyway, I suppose to support money fields properly, I should use
$dbh->column_info to sniff out money columns, and wrap all inserts /
updates on this field with a convert function? There's certainly no way
I can see that my current setup ( FreeTDS, DBD::ODBC ) will allow me to
use money columns otherwise.

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