Menu

No Cursor->Set???

Help
belsokar
2009-02-18
2013-04-09
  • belsokar

    belsokar - 2009-02-18

    Just wondering if I'm missing something?  I essentially want to open up a Cursor and have it move to the key I specify.  This is in a database that allows for duplicate entries.

    Example:

    I have a DBTree database with the following sample Key/Value pairs:

    akey01 -> data01
    akey01 -> data02
    akey01 -> data03
    bkey01->bdata01
    bkey01->bdata02
    bkey01->bdata03
    bkey01->bdata04

    I have created the above DB with the Duplicates flag set:

    db.SetFlags(DbFlags.Dup);

    Based on the Berkeley Db documentation, I should be able to do open up a cursor and do a Get to get me to the first duplicate record.

    "DB_SET" from the documentation (http://www.oracle.com/technology/documentation/berkeley-db/db/api_c/dbc_get.html)

    So let's say I wanted to step through all duplicate records with the key "bkey01" in the above example, then it would move to the first record ("bdata01"), and I should be able to step through those 4 duplicates using cursor.Get with the 'DbFileCursor.GetMode.NextDup' flag.

    The only way I'm seeing to do that right now is just Open up the cursor to the First record in the database, and then do a NoDup lookup for correct key, and then do a NextDup to grab the correct data items...but that would be a bit inefficient.

    thanks!

     
    • belsokar

      belsokar - 2009-02-18

      I guess I'm just blind, and it took me posting a question to find the answer!

      status = cursor.GetAt(ref keyEntry, ref dataEntry, DbFileCursor.GetAtMode.Set, DbFileCursor.ReadFlags.None);

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.