bind_param oddity?



Hi guys,

I'm sure I'm missing something *very* obvious but this one has me
scratching my head. Using DBI 1.52, DBD::mysql 3.0007, Perl 5.8.8,
MySQL 5.0.18.

The following code executes fine:

my $table = 'CCHISTORY';
my $status = 'D';
my $limit = 86400;

my $SQL = <<EOSQL;
select count(*) from $table
where TRXSTATUS = '$status'
and (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(TRXTIMESTAMP)) < $limit
EOSQL

my $sth = $dbh->prepare($SQL) || die $DBI::errstr, "\n";
$sth->execute() || die $sth->errstr(), "\n";

Now, because I want use use placeholders instead, I attempt the following:

my $SQL = <<EOSQL;
select count(*) from ?
where TRXSTATUS = ?
and (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(TRXTIMESTAMP)) < ?
EOSQL

my $sth = $dbh->prepare($SQL) || die $DBI::errstr, "\n";

my $table = 'CCHISTORY';
my $status = 'D';
my $limit = 86400;

my @bindParams = ($table, $status, $limit);
$sth->execute(@bindParams) || die $sth->errstr(), "\n";

Which fails with:

You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server for the right syntax to use near
''CCHISTORY'
and TRXSTATUS = 'D'
and (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(TRXTIMEST' at line 1

Anyone see an obvious error in my code that I'm overlooking?

Thanks.

--
Kevin.
.



Relevant Pages

  • Re: bind_param oddity?
    ... The following code executes fine: ... where TRXSTATUS = '$status' ... You have an error in your SQL syntax; ... corresponds to your MySQL server for the right syntax to use near ...
    (perl.dbi.users)
  • Re: DELETING records using MYSQL Database
    ... you don't have the rights for a local infile operation for that mysql ... ask the Perl Guys to run the infile op as a perl script with your file - ... mySql / VFP / MS-SQL ... > remote table - DELETE FROM, I want to repopulate it with data from ...
    (microsoft.public.fox.vfp.queries-sql)
  • script help to update member profiles
    ... form is all stored in a MySql Database (First Name, Last Name, Username, ... my partner that did all the perl scripts was injured ... Compare entered username and password to database to confirm the user is ...
    (comp.lang.perl.misc)
  • DBI / DBD / MySQL installation problem
    ... I used to run Red Hat 9, and had a perfect relationship with Perl, DBI, ... able to connect to MySQL from Perl via DBI. ... Running install for module Mysql ...
    (perl.dbi.users)
  • unable to make SELECT take variables
    ... I am working on a MySQL /Perl web site. ... PERL and am making progress. ... I want to sort and print the mailing labels from the database. ...
    (perl.dbi.users)