Subject: | cannot update/insert smalldatetime and money fields |
hi
we have problems with this DBD::ODBC driver. i have tested with this problem only the 0.43 and 0.48_? - but i haven't seen any fixes in the changes - therefor i think it is inside 1.01, too.
here a example code - not working
1. $timestamp is a Unix Timestamp!
2. DAYSTAMP is a smalldatetime field
my ($day,$mon,$year) = (localtime($timestamp))[3,4,5];
my $onlydate = sprintf("%02d.%02d.%04d",$day,$mon+1,$year+1900);
my $sth=$dbh->prepare("UPDATE $dbtable_stats SET ORDERS_NEW_EUR=ORDERS_NEW_EUR+? WHERE (PARTNER=?) AND (DAYSTAMP=?)");
my $howmany=$sth->execute($diffvalue,$partner,$onlydate);
if ($howmany eq '0E0') {
$sth=$dbh->prepare("INSERT INTO $dbtable_affilian_stats (ORDERS_NEW,ORDERS_NEW_EUR,PARTNER,DAYSTAMP) VALUES (?,?,?,?)");
$sth->execute(1,$new_value,$partner,$onlydate);
}
$sth->finish();
the following will work - but i do not realy like this...
my $sth=$dbh->prepare("UPDATE $dbtable_stats SET ORDERS_NEW_EUR=ORDERS_NEW_EUR+? WHERE (PARTNER=?) AND (DAYSTAMP=CONVERT(varchar(10), ?, 104))");
my $howmany=$sth->execute($diffvalue,$partner,$onlydate);
if ($howmany eq '0E0') {
$sth=$dbh->prepare("INSERT INTO $dbtable_affilian_stats (ORDERS_NEW,ORDERS_NEW_EUR,PARTNER,DAYSTAMP) VALUES (?,?,?,CONVERT(varchar(10), ?, 104))");
$sth->execute(1,$new_value,$partner,$onlydate);
}
$sth->finish();
a convert to smalldatetime is working too...
additional to this - maybe the same source of problem... i have set up a MONEY column and tryed to update... this isn't working too! for more details about i need to review my tests - done some months ago. i have worked around by changing the field to float... but this is unpossible in future. i need to integrate the perl into a existing DB and there are very very often money fields... this will break my app :-(
i hope you are able to help me about this... all this updates/inserts works with sql query and sql2k enterprisemanager...
Kind Regards
Marc Bauer