databaseesentedb

Dumping entries of a table index


I am trying to seek within the primary index of a table on a customers EDB database. And I fail miserably. I retrieved the index info using JetGetIndexInfo and know all about the index (it's the primary index and I know the column that's used). Now I want to seek on that index for known and existing values in order to maximize the performance, but JetSeek claims that it can't find the key I want to search for.

Now I am looking for a way to dump the index keys. That way I could see if I should add something to the key I am using or convert it somehow (I am absolutely sure it's the right key). Or is there another trick to find what's going wrong?

One detail that might be the reason for my failure could be the entry in KeyFldIDs column in the MSysObjects table. The particular index has some entry there. If I create an index myself that field is usually blank. What does it do?


UPDATE @Laurion: I've managed to run dbutil on the database. Here's the extract which is relevant:

AdditionalData
AttId
    Coltyp:     Binary
    Columnid:   2.147.483.777
    Max length: 8
    Grbit:      None
MsgFolderIndex6
    Grbit:          IndexUnique, IndexPrimary
    CultureInfo:    en-US
    CompareOptions: IgnoreCase, IgnoreKanaType, IgnoreWidth
        AttId
            Coltyp:      Binary
            IsAscending: True
            IsASCII:     False

Solution

  • For that index, this sequence of calls should work:

    JetOpenTable(...)
    JetMakeKey(sesid, tableid, pvData, cbData, JET_bitNewKey);
    JetSeek(sesid, tableid, JET_bitSeekEQ);
    

    If you want to dump the index keys you could do this:

    JetOpenTable(...);
    Use JetGetTableColumnInfo to get the ID of the column called "AttId"
    Use JetMove to walk the table sequentially, retrieving and dumping the column values
    

    The most likely error is that you are passing in an incorrect cbData value when making the key, possibly an off-by-one error, or sizeof() problem.