Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic


Locate and retrieve the next resource in a table.


CTDBRET ctdbDECL ctdbNextResource(CTHANDLE resource, CTBOOL lock)


ctdbNextResource() retrieve the next resource stored in a table. The resource parameter is a handle allocated with ctdbAllocHandle(). lock is used to indicate if the resource should be locked, if it is found. To retrieve all of the resources stored in a table, call ctdbNextResource() and then call this function until it returns RNOT_ERR (408). To retrieve all the resources stored in a table starting from a given resource type and number, allocate a resource handle, set the resource type and a resource number, and then call this function until it returns RNOT_ERR (408).


ctdbNextResource() returns CTDBRET_OK on success. After the last resource has been retrieved from the table, ctdbNextResource() returns RNOT_ERR (408).


/* read resources with type >= type and number > 0 */

CTDBRET DisplayResources(CTHANDLE hTable, ULONG type)



CTHANDLE hRes = ctdbAllocResource(hTable, type, 0, NULL);

/* check if resource was allocated */

if (!hRes)

return ctdbGetError(hTable);

/* note that no resource locks are acquired since we are not changing the resources */

while ((eRet = ctdbNextResource(hRes)) == CTDBRET_OK)


/* display resource type, number and name */

printf("Resource type: %u, number: %u", ctdbGetResourceType(hRes), ctdbGetResourceNumber(hRes));

if (ctdbGetResourceName(hRes) != NULL)

printf(", name: \"\"\n", ctdbGetResourceName(hRes));


printf(", name: NULL"\n");



return eRet;


See Also

ctdbAllocResource(), ctdbFreeResource(), ctdbAddResource(), ctdbDeleteResource(), ctdbUpdateResource(), ctdbFirstResource(), ctdbFindResource(), ctdbFindResourceByName(), ctdbGetResourceType(), ctdbGetResourceNumber(), ctdbSetResourceNumber(), ctdbGetResourceName(), ctdbSetResourceType(), ctdbGetResourceDataLength(), ctdbGetResourceData(), ctdbSetResourceData(), ctdbIsResourceLocked(), ctdbUnlockResource()