How do I iterate over two Berkeley DBs at the same time, advancing a cursor where appropriate (ex: the keys in one db is less than the other) in Perl?
Asked
Active
Viewed 294 times
2
-
I'm not that familiar with Berkeley DB, but I cannot imagine that this is possible. – Matt Ball Mar 03 '11 at 04:04
-
I don't know Berkeley DB either, but can't you just use the cursors (see http://search.cpan.org/perldoc?BerkeleyDB#CURSORS) to move through the database one row at a time? – Gaurav Apr 30 '11 at 05:26
1 Answers
1
I'm not 100% sure what you're trying to do, but my suggestion would be to open two separate cursors, let's call them A and B. I'm assuming A is the outer iteration and B is the inner iteration. Start by iterating on cursor A (set the initial cursor location and go into your "getnext" loop). For each record that you get from A, set the initial cursor position for cursor B and iterate until you've seen the records that you want from B. Then advance to the next A, lather, rinse and repeat.
You might also want to ask this question (with a few more details) on the Berkeley DB forum.