Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Going to first record on a record set in DBI

by edan (Curate)
on Jul 21, 2003 at 12:58 UTC ( #276246=note: print w/replies, xml ) Need Help??


in reply to Going to first record on a record set in DBI

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...

HTH

--
3dan

Replies are listed 'Best First'.
Re: Re: Going to first record on a record set in DBI
by sgifford (Prior) on Jul 21, 2003 at 15:54 UTC
    The other option, if the first records set is very large, is to just repeat the query.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://276246]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2023-06-01 11:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?