How to get GetNext-requests to work on dynamic tables from DB

Alex Finogenov afinogenov____malibunet.com
Fri Mar 22 19:47:32 CET 2002


Kjersti,

Using index of each varbind in the request, you have to fetch the NEXT (using whatever criteria applies in your application) row for EACH such varbind (a simple optimization will allow you not to fetch the same row more than once). When you reached the end of your DB for a particular SNMP table, i.e. there are no more NEXT objects in your DB related to that SNMP table, you must load the FIRST respective object in accordance with the same criteria.

I hope I answered the right question. :)

Alex

> -----Original Message-----
> From: Kjersti Grønnevik [mailto:kgr____morecom.no]
> Sent: Friday, March 22, 2002 6:59 AM
> To: agentpp-dl____agentpp.com
> Subject: How to get GetNext-requests to work on dynamic tables from DB
> 
> 
> Hi
> 
> I have problems with the getNext-request in my dynamic table 
> I fetch up from DB every time I get a new request.
> 
> After every finished request I delete every row I have 
> fetched from DB for that particularly request.
> If I then get a new request of the type 
> GetNext(oid.getNext...), I get the row of the oid before 
> (like, get next oid in same row...)
> and the next oid in the same row in the next collumn, which 
> is wrong. What I want is to get the next row in the DB and 
> from that row - the oid in the same collumn and the next row.
> 
> Are there any things I have overssen here? or some tricks I 
> can add to my code?
> 
> Hope this is understandable and thanks so much for great help so far!
> 
> Best regards,
> Kjersti
> 
> Here's some of my kode, maybe it will help to get my point clearer.
> 
> void lvAptEntry::update(Request* req, int subReqIndex)
> {
>   start_synch();
> 	
> 	currentSubReqIndex = subReqIndex;
> 	update( req );	
> 	lastReqId = req->get_request_id();
> 
> 	end_synch();
> }
> 
> void lvAptEntry::update(Request* req)
> {
> 	// clear table rows if this is a new request
> 	unsigned long currentReqId = req->get_request_id();
> 	if( lastReqId != currentReqId )
> 	{
> 		removeAllAPTEntries();
> 	}
>  	
>   Oidx oid = req->get_oid( currentSubReqIndex );
>   Oidx oid_aptId = getPrimaryKeyAsOID( oid ); //fetch the 
> index from the oid
> 
>   MibTableRow* existingRow = find_index( oid_aptId );
> 
> 	if( existingRow == 0 )
> 	{
>    	//fetch row from db
> 		long aptId = getPrimaryKeyAsLong( oid );
> 		LVDatabase *db = LVDatabase::getInstance();
> 
> 		APTEntry aptEntry;
> 
> 		if(req->get_type() == 160)
> 		{
> 			aptEntry = db->getAPTEntry( aptId );
> 		}
> 		else if(req->get_type() == 161)
> 		{
> 		    	aptEntry = db->getNextAPTEntry( aptId );
> 		}
> 
> 		addEntry( aptEntry, oid_aptId );  // add the 
> row with the row data from db
> 	}	
> }
> 
> Oidx lvAptEntry::find_succ(const Oidx& oid, Request* req)
> {
> 	/*Oidx oid_aptId = getPrimaryKeyAsOID( oid ); //fetch 
> the index from the oid
> 	MibTableRow* existingRow = find_index( oid_aptId );
> 	if( existingRow == 0 )
> 	{
>    	long aptId = getPrimaryKeyAsLong( oid );
> 		LVDatabase *db = LVDatabase::getInstance();
> 		APTEntry nextAptEntry = db->getNextAPTEntry( aptId );
> 		
> 		 // add the row with the row data from db
> 		addEntry( nextAptEntry, oid_aptId );
> 	} */
> 
>   MibLeaf* leaf = find_next( oid );
>   if( leaf )
> 		return leaf->get_oid();
> 	else
> 		return Oidx();
> }
> 
> void lvAptEntry::addEntry( APTEntry& entry, const Oidx& oid_aptId)
> {
> 	MibTableRow* newRow = add_row( oid_aptId );
> 	LVDatabase *db = LVDatabase::getInstance();
> 
>   	set_row(
> 		newRow,
> 		(long)entry.getId(),
> 		(char*)entry.getFriendlyName().c_str(),
> 		.....
> }
> 
> Oidx lvAptEntry::getPrimaryKeyAsOID( const Oidx& oid )
> {
> 	return oid.cut_left( 16 );//fetch the db primary key 
> from the oid
> }
> 
> long lvAptEntry::getPrimaryKeyAsLong( const Oidx& oid )
> {
> 	return oid.last();
> }
> 
> void lvAptEntry::removeAllAPTEntries()
> {
> 	 	//remove old rows from MibTable
> 		clear();
> 		delete_rows.clearAll();
> 		notready_rows.clearAll();
> }
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.agentpp.org/pipermail/agentpp/attachments/20020322/c3f12465/attachment.htm 


More information about the AGENTPP mailing list