Hello Monks,

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,


In reply to prepare_cached warning by HarshaHegde

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.