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 functionality is required without terminating the existing connection and starting a new c-treeDB session. The following methods are available to permit a session handle to be attached and detached from an existing c-tree connection.
CTSession::Attach() attaches an inactive session handle to an existing c-tree Plus or c-treeDB session. Attached sessions have no information on server, user name or user password, and these values are set to NULL. If a Logout() is performed on an attached session handle, no session logout is performed and a DetachSession() call is executed instead.
There are three valid mode values:
mode Parameter |
Description |
CTATTACH_SESSION |
Attach to a c-treeDB session whose session handle is pointed by parameter source. |
CTATTACH_CTREEID |
Attach to a c-tree Plus 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. |
CTSession::Detach() detaches a c-treeDB 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 AllocSesison(). DetachSession() returns CTDBRET_OK on success.