Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

DBI and money columns

by nop (Hermit)
on Aug 31, 2000 at 05:55 UTC ( [id://30456]=perlquestion: print w/replies, xml ) Need Help??

nop has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I'm using DBI::ODBC to MS Sqlserver.
I'm having type mismatch errors when I try to
insert / update values into money columns
using place holders. How do I indicate a column type?
Thanks!

Replies are listed 'Best First'.
Re: DBI and money columns
by PotPieMan (Hermit) on Aug 31, 2000 at 06:57 UTC
    I haven't coded in the DBI for a while now. Nonetheless, I would try binding parameters using $sth->bind_param(). For instance, given that $dbh is a valid database handler:
    $sth->prepare("UPDATE table SET column_1 = ? WHERE id = 1"); $sth->bind_param(1, 221783, { TYPE => SQL_VARCHAR }); $sth->execute();
    According to Programming the Perl DBI, DBD::ODBC supports placeholders, so hopefully this will work.

    This does not mean that the module supports money columns--you'll have to try the type_info() and type_info_all() methods, as in:

    print $dbh->type_info_all();
    This will (hopefully) return all the datatypes supported by Microsoft SQL Server and DBD::ODBC. I can't really answer for sure, as I do not use SQL Server or ODBC.

    Hope this helps.

    -ppm

Re: DBI and money columns
by ncw (Friar) on Aug 31, 2000 at 10:54 UTC
    We used this for a while at work, ie MS SQL Server with DBI & DBD::ODBC & openlink. I seem to remember that the money field is buggy in DBD::ODBC or maybe it was in the openlink driver.

    My memory of the problem was that money fields needed to be strings when input to the DBI ie in '', sending them as numbers ie without '' or as placeholders didn't work. (Or possibly the other way round - it was a while ago now.) I remember that we could never get the money fields to be entered as placeholders though.

    We solved this problem (and many others) by switching to MySQL ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://30456]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-24 22:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found