This discussion is archived
2 Replies Latest reply: Aug 23, 2011 9:59 AM by Andrei Costache, Oracle RSS

Why I cann't read content for a database ?

856797 Newbie
Currently Being Moderated
I copy a database from other place,and open it successfully, but I cann't read content by using cursor;In addition,I can write to it ,then,I can read the content that I write only;I am sure that it is not empty,because I can dump the content accoss the command db4.8_dump.The followng is the main code:
u_int32_t env_flags = DB_CREATE
     | DB_INIT_LOCK
     | DB_INIT_LOG
          | DB_INIT_MPOOL
          | DB_INIT_TXN
     | DB_RECOVER
| DB_THREAD;
std::string envHome("/home/bruce/Desktop/dbobject0/");
u_int32_t db_flags = DB_AUTO_COMMIT
     | DB_CREATE
     | DB_THREAD;
std::string dbName("test.db");
DbEnv* myEnv = NULL;
Db* myDb = NULL;
myEnv= new DbEnv(0);
myEnv -> set_cachesize(0,1*1024*1024,0);
myEnv->open(envHome.c_str(),env_flags,0);
          
myDb = new Db(myEnv,0);
myDb->open(NULL,dbName.c_str(),envHome.c_str(),DB_BTREE,db_flags,0);
Dbt key, value;
key.set_flags(DB_DBT_MALLOC);
value.set_flags(DB_DBT_MALLOC);
int res = cursorp->get(&key, &value, DB_FIRST);


every time the res == NOTFOUND

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points