Skip to Main Content

Berkeley DB Family

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

error, when try to get a join cursor count

544930Feb 7 2007 — edited Feb 7 2007
I have a primary db, and two secondary db.
do a join of two cursors of the two secondary db.
get the selected results from primary db correctly
but it failed when I try to get count of the join cursor.

thanks

Db pdb(...);
Db sdb1(...);
pdb.associate(NULL, &sdb1, getKey1, 0);
Db sdb2(...);
pdb.associate(NULL, &sdb2, getKey2, 0);

Dbt data;

string t("aaa");
Dbt key((void*) t.c_str(),(u_int32_t) t.length() +1);
Dbc *cursor1;
sdb1.cursor(NULL,&cursor1,0);
int retl = cursor1->get(&key, &data, DB_SET);
db_recno_t recno;
cursor1->count(&recno,0);
cout<<"#records found "<<recno<<endl; // no problem here

string t2("asdf");
Dbt key((void*) t2.c_str(),(u_int32_t) t.length() +1);
Dbc *cursor2;
sdb2.cursor(NULL,&cursor1,0);
int ret2 = cursor1->get(&key, &data, DB_SET);
db_recno_t recno2;
cursor2->count(&recno2,0);
cout<<"#records found "<<recno2<<endl; // no problem here

// Set up the cursor array
Dbc *carray[3];
carray[0] = cursor1;
carray[1] = cursor2;
carray[2] = NULL;

// Create the join
Dbc *join_curs;
int ret = pdb.join(carray, &join_curs, 0) ;
if (!ret)
{
// Iterate using the join cursor
while ((ret = join_curs->get(&key, &data, 0)) == 0) {
//get selected record from pdb, no
problem
}

db_recno_t recno;
join_curs->count(&recno,0); // error
here !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!??????????
cout<< recno <<endl;

if (cursor1 != NULL) cursor1->close();
if (cursor2 != NULL) cursor2->close();
if (join_curs != NULL) join_curs->close();
}
else
cout<<0<<endl;

}catch (DbException &e){
cout<<e.what()<<endl;
return (e.get_errno());
}catch(exception &e){
cout<<e.what()<<endl;
return (-1);
}
return true;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 7 2007
Added on Feb 7 2007
2 comments
860 views