campbell has asked for the wisdom of the Perl Monks concerning the following question:
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!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: I seek DBI wisdom concerning bind parameters
by graff (Chancellor) on Oct 22, 2015 at 16:39 UTC | |
by campbell (Beadle) on Oct 23, 2015 at 13:35 UTC | |
Re: I seek DBI wisdom concerning bind parameters
by fishmonger (Chaplain) on Oct 22, 2015 at 16:23 UTC | |
Re: I seek DBI wisdom concerning bind parameters
by 1nickt (Canon) on Oct 23, 2015 at 06:23 UTC | |
Re: I seek DBI wisdom concerning bind parameters
by SimonPratt (Friar) on Oct 23, 2015 at 10:42 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |