how to copy a cursor? check my code please? - berkeley-db
This is a discussion on how to copy a cursor? check my code please? - berkeley-db ; The function below is supposed to accept a database and a read cursor, and create a write cursor pointing to the the same record. It is supposed to work for databases with duplicate keys allowed (a requirement - although the ...
![]() |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| |||
| |||
| It doesnt work. the write cursor get function always returns DB_NOTFOUND and I cant figure out why. thanks for any help you can give. Steve int DBUtil::createWriteCursor(Db* database, Dbc* readCursor, Dbc** writeCursor) { int result; *writeCursor = NULL; Dbt key; Dbt data; memset((void*) &key, 0, sizeof(Dbt)); memset((void*) &data, 0, sizeof(Dbt)); // first get the key and data from the current cursor, which represents a unique combination result = readCursor->get(&key, &data, DB_CURRENT); if (result != 0) return result; try { // open the writecursor database->cursor(NULL, writeCursor, DB_WRITECURSOR); } catch(DbException ex) { return -1; } // move the cursor to the position in the database that matches the combo result = (*writeCursor)->get(&key, &data, DB_GET_BOTH); if (result != 0) (*writeCursor)->close(); // will return 0 on success, or DB_NOTFOUND if some other error return result; |
|
#2
| |||
| |||
|
To put it another way - why does cursor->get(key,data, DB_GET_BOTH) return DB_NOT_FOUND? clearly in my code the key and data contain valid information because I just read it! confused... |
![]() |
« Previous Thread
|
Next Thread »
| Thread Tools | |
| Display Modes | |
| |
All times are GMT -4. The time now is 09:47 AM.




Linear Mode