Greetings, fellow monks
I seek some DBI wisdom.
I am using the following code to extract some data from our MS-SQL database using Perl version 5.8.8: (I've snipped out the irrelevant stuff for clarity and conciseness)
use strict; use warnings; use DBI; <snip> my $dbh=DBI->connect('dbi:ODBC:DSN='.$DSN, $USER, $PSWD) or die "Could +n't connect to database: ".DBI->errstr; my $fieldquery=" SELECT <Snip> FROM <Snip> WHERE PlanSetup.PlanSetupSer=? <snip the rest of the where clause> "; my $sth_fields=$dbh->prepare($fieldquery) or die "Couldn't prepare sta +tement: " . $dbh->errstr; <Snip some stuff to get $plansetupser> $sth_fields->execute($plansetupser) or die "Couldn't execute statement +: ".$sth_fields->errstr;
The trouble is, when I try to run this statement, I always get the error message:
Couldn't execute statement: called with 1 bind variables when 0 are needed at line <snip>I just don't understand why it says that it doesn't need a bind variable when I have definitely put a question mark in the SQL. I've tried various other things instead of the question mark, like :parameter, but these have the same effect. There's clearly something up with my syntax, but I'm stumped as to what it is...
I hope this is enough to go on, and thanks in advance for any help!In reply to I seek DBI wisdom concerning bind parameters by campbell
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |