0

As you see in the title, I want to retrieve data whose key is less than a specified key, and then I need to join many cursors which one could be more than a specified string, and another might be less than a specified integer. By default, the DB_SET_RANGE will return keys that are greater or equal than specified key.

Should I implement it using a rewrite of comparison function, and set it as the comparison function of database, just like set_bt_compare()?

Thank you!

Peiyun
  • 149
  • 1
  • 7

1 Answers1

0

I think you'll find that you still need your own loop around DB_NEXT or DB_PREV, with your own logic for comparing the keys and exiting the loop on more complex conditions.

You could use DB_SET_RANGE to find the point where the keys are greater, then turn around and go backwards with DB_PREV. Or, you could start at the beginning of the database with DB_FIRST and scan ahead with DB_NEXT until you reach the point where they're greater.

Mike Andrews
  • 3,045
  • 18
  • 28