HarshaHegde has asked for the wisdom of the Perl Monks concerning the following question:
I have a question about prepare_cached() statements. The relevant extract from my script runs like this:
sub get_account_status { my ($account_num) = shift; my $query = qq { SELECT a.STATUS FROM account a WHERE a.ACCOUNT_NUMBER = ? }; my $sth = $dbh->prepare_cached($query); $sth->execute($account_num); my $status = $sth->fetchrow_array; return uc($status); }
And when I run this I get this warning: "statement handle still active at <line number of the prepare_cached statement>".
After fetching the result, if I say,
$sth->finish;
then the warning vanishes. So I thought that there might be multiple status values for each account number and I might not be fetching all of them. But given the fact that account number is the primary key on this table, this seemed impossible. Also, if I query the table directly, I get only one status value for each account number.
I believe, I am not properly using prepare_cached (and yes, this is the first time I am using it!!).
Any suggestions??
Thanks,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: prepare_cached warning
by runrig (Abbot) on Jun 15, 2007 at 18:39 UTC | |
by HarshaHegde (Sexton) on Jun 15, 2007 at 19:19 UTC | |
by runrig (Abbot) on Jun 15, 2007 at 20:04 UTC | |
|
Re: prepare_cached warning
by pajout (Curate) on Jun 16, 2007 at 16:38 UTC |