Product Documentation

FairCom DB API for C

Previous Topic

Next Topic

Updating Existing Resources

An existing resource can be updated by calling the following function:

CTDBRET ctdbDECL ctdbUpdateResource(CTHANDLE resource, pVOID data, VRLEN size);

You must call ctdbAllocResource() with specific resource type and number that will uniquely identify the resource being updated.

  • resource is a resource handle allocated by ctdbAllocResource().
  • data is any collection of data that you wish to store as a Resource. It can be a character string, a structure, or any variable type.
  • size indicates the number of bytes occupied by data parameter value. ctdbUpdateResource() returns CTDBRET_OK on success.

FairCom DB API C API Update Resource Example

CTDBRET UpdateMyResource(CTHANDLE Handle, ULONG type, ULONG number, pTEXT name, pVOID data, VRLEN size)

{

CTDBRET Retval;

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

if (hRes)

{

if ((Retval = ctdbUpdateResource(hRes, data, size)) != CTDBRET_OK)

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

ctdbFreeResource(hRes);

}

else

{

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

Retval = CTDBRET_NOMEMORY;

}

return Retval;

}

TOCIndex