Product Documentation

FairCom DB API for C

Previous Topic

Next Topic

ctdbSwitchInstance

Force a c-tree instance switch.

Declaration

CTDBRET ctdbSwitchInstance(CTHANDLE Handle)

Description

Force a switch to the c-tree instance indicated by the Session handle. Each session handle has its unique c-tree instance ID.

When most FairCom DB API C functions are called, they automatically perform a c-tree instance switch. ctdbSwitchInstance() may be useful before calling specific c-tree ISAM or low level calls to make sure the correct instance is active before making those calls.

Handle is a Session handle. You can pass any FairCom DB API handle to ctdbSwitchInstance().

Return

Value

Symbolic Constant

Explanation

0

CTDBRET_OK

Successful function.

See FairCom DB API Errors and Return Values for a complete listing of valid FairCom DB API error codes and return values.

Example


/* declare and allocate the remote and local session handles */

CTHANDLE hRemote = ctdbAllocSession(CTSESSION_CTREE);

CTHANDLE hLocal = ctdbAllocSession(CTSESSION_CTREE);


/* logon to c-tree server using the remote session handle */

if (ctdbLogon(hRemove, "FAIRCOMS", "ADMIN", "ADMIN") != CTDBRET_OK)

printf("Remote ctdbLogon failed\n");

/* logon to local session using the local session handle */

if (ctdbLogon(hLocal, "local", "ADMIN", "ADMIN) != CTDBRET_OK)

printf("Local ctdbLogon failed\n");

/* perform a c-tree instance switch and call CtreeUserOperation function */

if (ctdbSwitchInstance(hRemote) != CTDBRET_OK)

printf("ctdbSwitchInstance failed\n");

CtreeUserOperation("!mkdir faircom", buffer, sizeof(buffer);

See also

ctdbSwitchContext(), ctdbGetDatno(), ctdbGetIdxno(), ctdbGetIdxnoByName(), ctdbGetIdxnoByNumber()

TOCIndex