dbTalk Databases Forums  

error, when try to get a join cursor count

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


Discuss error, when try to get a join cursor count in the comp.databases.berkeley-db forum.



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

Default error, when try to get a join cursor count - 02-07-2007 , 02:19 AM






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;


Reply With Quote
  #2  
Old   
michael.cahill@gmail.com
 
Posts: n/a

Default Re: error, when try to get a join cursor count - 02-08-2007 , 11:11 PM






Hi,

Quote:
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.
The documentation for DB->join is here:

http://www.oracle.com/technology/doc...y-db/db/api_c/
db_join.html

In particular, join cursors do not support the count method. Just
increment a counter in the "get" loop.

Regards,
Michael Cahill, Oracle.



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.