in reply to Re: DBD::ODBC, Access, date comparisons
in thread DBD::ODBC, Access, date comparisons
This seems to insert the hash-marks properly into the strings, because the print("Report...") statement works correctly, but ODBC poops on me like thismy $report_date = "\#".&UnixDate(&ParseDate("3/19/2003"), "%m%/ +%d%/%Y")."\#"; my $start_date = "\#".&UnixDate(&ParseDate("3/19/2003"), "%m%/% +d%/%Y")."\#"; my $end_date = "\#".&UnixDate(&ParseDate("3/20/2003"), "%m%/%d% +/%Y")."\#"; my ($DaysOpen, $Priority, $Status) = undef; my ($WO2, $Ticket, $DateOpened, $ClearDate, $SiteCode, $Problem1, $Si +teCall1, $Dispatch, $Troubleshooting, $Solution1 )= undef; $sqlstatement= qq ( SELECT WorkOrd.WO2, WorkOrd.ClearDate from WorkOrd where WorkOrd.StatCode5 = 'C' and ( WorkOrd.ClearDate is NULL or ( WorkOrd.ClearDate BETWEEN ? and ? ) ) ); print("Report run on $report_date \t Report runs from $start_date to $ +end_date.\n"); $sth = $dbh->prepare($sqlstatement) or die "Could not prepare stateme +nt. Error:$sth->errstr()\n"; $sth->execute($start_date, $end_date) or die "Could not execute state +ment. Error:$sth->errstr()\n";
If I don't use placeholders, I get this:DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access Driver +] Data type mismatch in criteria expression. (SQL-22005)(DBD: st_execute/SQLExecute err=-1) + at O:\Scripts\Perl\ServiceReports\av-citigroup.pl line 54. Uncaught exception from user code: Could not execute statement. Error:DBI::st=HASH(0x21181c8)->errstr +() Report run on #03/19/2003# Report runs from #03/19/2003# to #03/2 +0/2003#.
Report run on #03/19/2003# Report runs from #03/19/2003# to #03/2 +0/2003#. 38706 2003-03-19 14:17:01 38747 2003-03-19 18:40:42 38803 2003-03-19 15:26:40 38848
|
|---|