awohld has asked for the wisdom of the Perl Monks concerning the following question:

I'm using DBD::CSV and trying to use placeholders. My problem is that when I try to use placeholders I'm not getting any data back. Here's my code:
my $sth = $dbh->prepare("SELECT ID, FRAMEID FROM SECT WHERE SITEID = ? + AND OFFSET = ?") or die "Can't prepare SQL statement: $DBI::errstr\n"; $sth->execute("49","2") or die "Can't execute SQL statement: $DBI::errstr\n";
When I look in the book "Programming the Perl DBI" it says taht DBD::CSV doesn't support the :1 placeholder style.

Is the above the ":1 placeholder style"? How do I get placeholders to work in the above code?

When I change the code to look like below, everything works fine, so I know there's some issue with how I'm using placeholders:
my $sth = $dbh->prepare("SELECT ID, FRAMEID FROM SECT WHERE SITEID = 4 +9 AND OFFSET = 2") or die "Can't prepare SQL statement: $DBI::errstr\n"; $sth->execute() or die "Can't execute SQL statement: $DBI::errstr\n";

Replies are listed 'Best First'.
Re: DBD::CSV :1 Syntax Placeholder
by jZed (Prior) on Sep 26, 2005 at 18:17 UTC
    No, that part of the doc does not refer to the style of placeholders you are using. The :1 style placeholder means that you number the placeholders instead of using question marks. The syntax you show should work with DBD::CSV (although I doubt you want quote marks around your execute values). What error message do you get, or what leads you to believe it doesn't work?
      I'm not getting any error message back, I'm just not getting any data back from my query. When I try using placeholders with only 1 place holder it works fine. But when I try to use more than one placeholder in a statment I don't get any data back from the query.
        What version of DBD::CSV and SQL::Statement are you using?
Re: DBD::CSV :1 Syntax Placeholder
by nedals (Deacon) on Sep 27, 2005 at 00:31 UTC
    Try it without the quotes.
    $sth->execute(49,2) or die "Can't execute SQL statement: $DBI::errstr\n";
      I tried that and I still can't get placeholders to work with DBD::CSV.