Using bind_param SQL_INTERVAL datatype with placeholder
S Kreisler <skreisle-cv/eCJ4TdN38+C6w/[email protected]>
| Newsgroups | gmane.comp.db.postgresql.dbdpg |
|---|---|
| Message-ID | <[email protected]> |
Hi!
Is there a way to use the SQL_INTERVAL datatype with a placeholder? The
following works correctly without the third param (i.e., "where date
between ? and ?"), but not with the interval parameter. Any suggestions?
Thanks!!
---------------------------
use DBI qw(:sql_types) ;
use strict;
my $dbh = connect_to_db();
my $query = qq{
select *
from sciencedata
where date between ? and ? + ?
};
my $sth = $dbh->prepare($query);
$sth->bind_param(1, undef, SQL_TIMESTAMP);
$sth->bind_param(2, undef, SQL_TIMESTAMP);
$sth->bind_param(3, undef, SQL_INTERVAL);
my $date1 = '7/1/06';
my $date2 = '7/15/06';
my $interval = '2160 minutes';
$sth->execute($date1,$date2,$interval);
my @output = $sth->fetchrow_array;
print "@output\n";
------------------------------