in reply to DBI quoting when I don't want it to

Here's some code for a Postgres DB that may help:
my $db; # local connection used to retrieve time $db = ... however you choose to connect a handle =item timestamp($timestring [, $future_flag]) =cut sub timestamp { my($time,$future) = @_; local($db->{RaiseError}) = 0; local($db->{PrintError}) = 0; # Timestamp could be absolute. my $val = scalar $db->selectrow_array(q!SELECT EXTRACT('EPOCH' FROM TIMEST +AMP ?)!, undef, $time); if (defined $val) { $db->commit; return $val; } # Well, it's not, so let's try it again as a delta from today. $db->rollback; $val = scalar $db->selectrow_array(q! SELECT EXTRACT('EPOCH' FROM (TIMESTAMP 'now' + INTERVAL ?))!, { }, $time); return $val unless !defined($val) or (($val >= time) and !$future) +; # Hmm, that gave us nothing, or a time in the future, and the call +er # didn't want that. Try one more time, using a subtraction on the # delta. $db->rollback; $val = scalar $db->selectrow_array(q! SELECT EXTRACT('EPOCH' FROM (TIMESTAMP 'now' - INTERVAL ?))!, { }, $time); return $val; }
The only disadvantage of this approach that I've seen, is that error messages are logged in the postmaster log file whenever you pass through one of the try-again cases.
-- 
Jeff Boes                            vox 269.226.9550 ext 24
Database Engineer                           fax 269.349.9076
Nexcerpt, Inc.                       http://www.nexcerpt.com
        ...Nexcerpt...Connecting People With Expertise

Edit kudra, 2002-08-22 s/pre/code/