My code looks like this:
|timeIndex = new Db( _env, 0 );|
|timeIndex->set_flags( DB_DUPSORT );|
|timeIndex->set_bt_compare( /* my cmp function */ );|
|timeIndex->open( NULL, filename, NULL, DB_BTREE, DB_CREATE, 0 );|
dataTable->associate( NULL, timeIndex, /* generate key function */,
If you have removed the secondary database before running this, and it does not work, I think the possible reasons are:
* The 'generate key function' does not work correctly. The function should return 0 if you want to index the record.
* There is error happening during above functions, but you haven't caught it.
I think you can check the 'generate key function' and check every bdb function's returning value(at least DB->open and DB->associate) and display error message when it does not return 0.
Also, I'm not sure about this sentence "Although primary database contains records before." do you mean your primary database is empty now when creating the secondary database ?
It is true that, adding/removing/updating records in primary database will modify the secondary database as well.
Winter, Oracle Berkeley DB