Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Tie'ing a dbh result set? (unknown size)

by tye (Cardinal)
on Jul 26, 2011 at 17:12 UTC ( #916804=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Tie'ing a dbh result set?
in thread Tie'ing a dbh result set?

Actually, as part of playing with a new toy I wrote, I noticed that for( @tiedarray ) actually deals with the size of the array changing each iteration so you don't need to know the number of records up-front like I initially worried. You can just always fetch at least one record ahead and return the size of what you have fetched so far -- for for( @tiedarray ) to work fine as an iterator.

- tye        


Comment on Re^3: Tie'ing a dbh result set? (unknown size)
Select or Download Code
Re^4: Tie'ing a dbh result set? (unknown size)
by jfroebe (Vicar) on Jul 26, 2011 at 17:29 UTC

    One teeny tiny problem with that.. if the size of the Tie'd array is say a maximum of 5000 entries, the 5001st will not be returned correctly to your for loop as the size of the array is 5000 not 5001. (assuming you grabbed the next 5,000 rows)

    One way around this is by Tie'ing the array to a hash where the key is the index value. The next grab could either replace the key/value pairs with 5001/row data or purge the hash data structure and assign a new one depending on which is better for the application in question. The FETCHSIZE() will have to report this pseudo size so the for loop thinks there is another entry to retrieve.

    The module Tie::File implements something similar.

    Jason L. Froebe

    Blog, Tech Blog

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2014-04-21 13:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (495 votes), past polls