in reply to DBI not letting bind varibles in if you use a varible for the statement.

Do you have the RaiseError attribute set to 1? If not, it could be possible that you previously assigned $sth to a *different* statement handle; then you tried to prepare this one, and there was an error, but you didn't see it, because you're not checking for errors. Could it be possible that $sth is still referencing the old statement handle, then? And that that old statement handle has 5 bind variables?

It sounds kind of farfetched, I know. :)

Anyway... try checking for errors on your prepare:

$sth = $dbh->prepare($SQL_STATEMENT) or die "Can't prepare $SQL_STATEMENT: ", $dbh->errstr;
Or turn on RaiseError, if you don't already have it on.

I've used this construct many, many times, so I'd say it's definitely something weird in your situation.

  • Comment on Re: DBI not letting bind varibles in if you use a varible for the statement.
  • Download Code