ctdbFirstResource
Locate and retrieve the first resource in a table.
DECLARATION
CTDBRET ctdbDECL ctdbFirstResource(CTHANDLE resource, CTBOOL lock);
DESCRIPTION
ctdbFirstResource() retrieve the first resource stored in a table.
RETURN
ctdbFirstResource() returns CTDBRET_OK on success. If there are no resources for the table, ctdbFirstResource() return RNOT_ERR (408).
EXAMPLE
CTDBRET DisplayAllResources(CTHANDLE hTable)
{
CTDBRET eRet;
CTHANDLE hRes = ctdbAllocResource(hTable, 0, 0, NULL);
/* check if resource was allocated */
if (!hRes)
return ctdbGetError(hTable);
/* get the first resource */
/* note that no resource locks are acquired since we are not changing the resources */
if ((eRet = ctdbFirstResource(hRes, false)) != CTDBRET_OK)
{
ctdbFreeResource(hRes);
return eRet;
}
/* get the other resources */
do
{
/* 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));
else
printf(", name: NULL"\n");
}
while ((eRet = ctdbNextResource(hRes, false)) == CTDBRET_OK);
ctdbFreeResource(hRes);
return eRet;
}
SEE ALSO
ctdbFreeResource(), ctdbAddResource(), ctdbDeleteResource(), ctdbUpdateResource(), ctdbAllocResource(), ctdbNextResource(), ctdbFindResource(), ctdbFindResourceByName(), ctdbGetResourceType(), ctdbSetResourceType(), ctdbGetResourceNumber(), ctdbSetResourceNumber(), ctdbGetResourceName(), ctdbSetResourceName(), ctdbGetResourceDataLength(), ctdbGetResourceData(), ctdbSetResourceData(), ctdbIsResourceLocked(), ctdbUnlockResource()