Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

Deleting Resources

A resource can be deleted from a table by calling the following c-treeDB API C API function:

CTDBRET ctdbDECL ctdbDeleteResource(CTHANDLE resource);

Before the resource can be deleted, the table must be opened with exclusive mode CTOPEN_EXCLUSIVE.

  • resource is a resource handle allocated by ctdbAllocResource(), and the resource type and resource number that identify this resource must be passed to ctdbAllocResource().

After the resource is deleted, its name, number and name are reset.

c-treeDB API C API Delete Resource Example


/* delete a resource */

CTDBRET DelMyResource(CTHANDLE Handle, ULONG type, ULONG number, pTEXT name)

{

CTDBRET Retval;

CTHANDLE hRes = ctdbAllocResource(Handle, type, number, name);

if (hRes)

{

if ((Retval = ctdbDeleteResource(hRes)) != CTDBRET_OK)

printf("ctdbDeleteResource failed with error %d\n", Retval);

ctdbFreeResource(hRes);

}

else

{

printf("Failed to allocate resource handle\n");

Retval = CTDBRET_NOMEMORY;

}

return Retval;

}

TOCIndex