in reply to Invalid character value for cast specification
The problem code is as follows:
The same code, but without the bound parameter worked correctly:my $sql = q{select * from accountaction where action_date > ?}; my $sth = $dbh->prepare($sql); $sth->execute('01-01-2006'); $sth->finish;
The issue was that DBD::ODBC did not like the MM-DD-YYYY date format.my $sql = q{select * from accountaction where action_date > '01-01 +-2006'}; my $sth = $dbh->prepare($sql); $sth->execute(); $sth->finish;
This likely occurs because SQL Server can have different date formats, e.g. DD-MM-YYYY for some locales. So to be safe it only allow the YYYY-MM-DD format.my $sql = q{select * from accountaction where action_date > ?}; my $sth = $dbh->prepare($sql); $sth->execute('2006-01-01'); $sth->finish;
This response is being added to a somewhat old node because it is the only relevant one I found using Super Search, and I would like to save future searchers some trouble.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Invalid character value for cast specification
by larrymcp (Novice) on Mar 29, 2013 at 02:42 UTC |