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

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

by tye (Sage)
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        

Replies are listed 'Best First'.
Re^4: Tie'ing a dbh result set? (unknown size)
by jfroebe (Parson) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://916804]
[Corion]: A good morning to you too, Discipulus!

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2018-05-21 07:20 GMT
Find Nodes?
    Voting Booth?