Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Berkely DB > error, when try...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 1710 of 1800
Post > Topic >>

error, when try to get a join cursor count

by "NM" <nittanymountain@[EMAIL PROTECTED] > Feb 7, 2007 at 12: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;
 




 2 Posts in Topic:
error, when try to get a join cursor count
"NM" <nittan  2007-02-07 00:19:04 
Re: error, when try to get a join cursor count
michael.cahill@[EMAIL PRO  2007-02-08 21:11:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Sun Jul 6 20:12:39 CDT 2008.