Subject Cursors
Author Malcolm Smith
I am using a cursor to fill some in-memory tables as follows:

* DBSpriteDetail is my in-memory table (template stringlist class)
* cirIPLookup is my TIB_Cursor with the SQL property as:

SELECT IPL_IPADDRESS, IPL_LOCAL
FROM IPLOOKUP
WHERE ID = :ID

My code:

for(int i = 0; i < DBSpriteDetail->Count; i++)
{
// move to the next record in memory
DBSpriteDetail->CurrentRecord = i;

// find the record with the IPLookupID values in the IPLOOKUP table
curIPLookup->Prepare();
curIPLookup->ParamByName("ID")->AsInteger =
DBSpriteDetail->Fields->IPLookupID;
curIPLookup->Execute();

// and assign the IPAddress and Local values
DBSpriteDetail->Fields->IPAddress =
curIPLookup->FieldByName("IPL_IPADDRESS")->AsString;
DBSpriteDetail->Fields->Local =
curIPLookup->FieldByName("IPL_LOCAL")->AsBoolean;

curIPLookup->Close();
}

I am basically looking up the IPAddress and Local field values based on an
ID value in another table - hence I have to do a query rather than just walk
through the records.

My question is whether this is the most efficient method (required to
prepare/close on each iteration).


Malcolm Smith
MJ Freelancing
ABN: 30 671 763 146
http://www.mjfreelancing.com

CORintel
ABN: 30 336 110 329