Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi All, I have a very peculiar bind_param problem. Below is the (leaned down code snippet) of a routine in a module i'm writing.
Below doesnt work
The bind_param above does not seem to be binding the parameter.sub load { my $class = shift; my $id = shift; my $dbh = Some::Class->get_dbh(); my $sth = $dbh->prepare(<<"ENDSQL"); SELECT field1, field2 FROM table WHERE id = ? ENDSQL my ($field1, $field2); eval { # need to figure out why this bind_param isnt working $sth->bind_param(1, $id); $sth->execute(); $sth->bind_col(1, \$field1); $sth->bind_col(2, \$field2); }; if($@){ print "There was a error"; } $sth->fetch(); $sth->finish(); }
Below does work
If i dont bind the param it works fine. Has anyone experienced this? Is this at the dbi or dbd level.sub load { my $class = shift; my $id = shift; my $dbh = Some::Class->get_dbh(); my $sth = $dbh->prepare(<<"ENDSQL"); SELECT field1, field2 FROM table WHERE id = $id ENDSQL my ($field1, $field2); eval { $sth->execute(); $sth->bind_col(1, \$field1); $sth->bind_col(2, \$field2); }; if($@){ print "There was a error"; } $sth->fetch(); $sth->finish(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI bind_param problems
by mpeppler (Vicar) on Dec 18, 2002 at 19:23 UTC | |
by Anonymous Monk on Dec 18, 2002 at 19:28 UTC | |
|
Re: DBI bind_param problems
by JamesNC (Chaplain) on Dec 18, 2002 at 19:20 UTC | |
|
Re: DBI bind_param problems
by runrig (Abbot) on Dec 18, 2002 at 19:02 UTC | |
|
Re: DBI bind_param problems
by Fletch (Bishop) on Dec 18, 2002 at 20:42 UTC | |
|
Re: DBI bind_param problems
by benn (Vicar) on Dec 18, 2002 at 19:31 UTC |