dbTalk Databases Forums  

usage for c_put & c_get??

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss usage for c_put & c_get?? in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
NightThunder
 
Posts: n/a

Default usage for c_put & c_get?? - 10-23-2006 , 05:10 AM






Hi, all.

I want to update a record during traversing all records.
so.. I write following code.
but i met an access violation..what's wrong?
Thanks for your reply, in advance...

===========================
DBT key, data;
DB_TXN *tid = NULL;
DBC *dbcp = NULL;
memset(&key, 0, sizeof(DBT));
memset(&data, 0, sizeof(DBT));
data.flags = DB_DBT_MALLOC;

ret = dbenv->txn_begin(dbenv, NULL, &tid, 0);
ret = dbp->cursor(dbp, tid, &dbcp, 0);
ret = dbcp->c_get(dbcp, &key, &data, DB_NEXT );

ret = dbcp->c_put(dbcp, &key, &data, DB_CURRENT); <--- A/V occurred.

For test, i update a record with same data DBT...
and all return values(ret) are checked...
traversing all records is okay, but when i add the last sentense, i met
the A/V error.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.