Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

Attach and Detach Existing Sessions

There are situations where an existing connection to c-tree already exists, via a call to a low level or ISAM c-tree initialization function, but c-treeDB API functionality is required without terminating the existing connection and starting a new c-treeDB API session. The following functions are available to permit a session handle to be attached and detached from an existing c-tree connection.

ctdbAttachSession() attaches an inactive session handle to an existing c-tree Plus or c-treeDB API session. Attached sessions have no information on server, user name or user password, and these values are set to NULL. If a ctdbLogout() is performed on an attached session handle, no session logout is performed and a ctdbDetachSession() call is executed instead.

There are three valid mode values:

mode Parameter

Description

CTATTACH_SESSION

Attach to a c-treeDB API session whose session handle is pointed by parameter source.

CTATTACH_CTREEID

Attach to a FairCom DB session whose instance id string is pointed by parameter source.

CTATTACH_CURRENT

Attach to the current c-tree instance. Contents of parameter source is ignored, as the c-tree instance id is obtained by calling WCHCTREE() function.

ctdbDetachSession() detaches a c-treeDB API session handle. The c-tree ISAM or low-level un-initialization is not called, but the session handle control structures are released and re-initialized. Handle is a session handle allocated by ctdbAllocSesison(). ctdbDetachSession() returns CTDBRET_OK on success.

Example


/* logon to c-tree using ISAM function */

INTISAMX(10, 32, 32, 10, (USERPRF_NTKEY | USERPRF_CLRCHK));

/* attach session to server handle */

if (ctdbAttachSession(hSession, NO) != CTDBRET_OK)

printf("ctdbAttachSession failed\n");

/*

... do something useful ...

*/

/* detach from session */

if (ctdbDetachSession(hSession) != CTDBRET_OK)

printf("ctdbDetachSession failed\n");

/* perform an ISAM logout */

CLISAM();

TOCIndex