Shuffling the code around won't help, and using
undef
won't destroy the cursor when you use prepare_cached,
because DBI will keep a reference to the $sth even if you don't. But
I would probably move the prepare_cached from inside the for
loop to
outside of the loop for a small efficiency gain (so you
don't have to refetch the $sth on every iteration of the loop).
Also, you don't need to call finish when you fetch all
of the rows from a cursor (it should only be used when you,
e.g., fetch the first n rows and then exit the loop early), and you don't need to undef
the $sth. And I would be cautious in using the fetchall_*
methods; if there are alot of rows it can eat up memory;
and if you don't really need the entire result set all
at once, you're just as well off just using fetch (maybe
even combined with bind_columns).
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.