Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

comment on

( [id://3333] : superdoc . print w/replies, xml ) Need Help??

Not to denigrate the previous replies to this question, and I might be just plain wrong, but it seems to me that the question being asked hasn't been answered. I think the OP wants to loop over each row in one record set for each row in another record set.

I would do the following to accomplish this, as illustrated by the following UNTESTED code snippet:

# first, get all the results for the record set used in inner loop my $record_set_1 = $sth1->fetchall_arrayref; # loop over second record set while (my @row = $sth2->fetchrow_array) { foreach my $row_from_record_set_1 (@$record_set_1) { # blah blah } }

Of course, if the first record set is very large, you'll run into memory problems. If that's the case, then you might be able to use cursors, depending on whether your DB supports it...



In reply to Re: Going to first record on a record set in DBI by edan
in thread Going to first record on a record set in DBI by chuleto1

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.