dbTalk Databases Forums  

Beginner need help

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


Discuss Beginner need help in the comp.databases.berkeley-db forum.



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

Default Beginner need help - 03-18-2006 , 03:16 AM






Hi,

When I want to put a record into my database which has been created
and opened in an environment with below code, It returns an "Invalid
argument"error, error number: 22.

code: (omit some...)

/**create env **/
……………………
penv->open(penv, "/root/db_ccurnt", DB_CREATE|DB_INIT_MPOOL, 0);
db_create(&usr, penv, 0);
usr->open(usr, NULL, "database", NULL, DB_BTREE, DB_CREATE,
0666);

usr->cursor(usr, NULL, &wcursor, 0);
key.data = xx;
key.size = strlen(xx) + 1;
value.data = yy;
value.size = strlen(yy) + 1;

ret = wcursor->c_put(wcursor, &key, &value, DB_KEYFIRST);
if (ret)
{
printf("error num: %d%s\n", ret, db_strerror(ret));
goto error;
}
Will anybody shed some shine for me?Thanks!


Reply With Quote
  #2  
Old   
Michael Cahill
 
Posts: n/a

Default Re: Beginner need help - 03-18-2006 , 04:50 AM






Do you do this:

memset(&key, 0, sizeof key);
memset(&value, 0, sizeof value);

before using the DBTs? If not, the other fields in the DBT struct will
lead to invalid argument errors.

Also, you should enable error messages with DB_ENV->set_errfile before
opening the environment. That should give more information when things
go wrong.

Regards,
Michael.


Reply With Quote
  #3  
Old   
wuxian610
 
Posts: n/a

Default re:Beginner need help - 03-18-2006 , 08:43 PM



Thanks for your help, Michael.


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.