Oracle 8i Data Cartridge Developer's Guide Release 2 (8.1.6) Part Number A76937-01 |
|
Using Cartridge Services, 3 of 9
Cartridge services require various handles that are encapsulated inside two types of OCI handles -
OCIEnv
or OCI_HTYPE_ENV
).
Various cartridge services are required at the process level when no session is available. The OCIInitialize
() should use the OCI_OBJECT
option for cartridge service.
OCISession
or OCI_HTYPE_SESSION
).
In a callout, the services can be used when the handle is allocated even without opening a connection back to the database.
All cartridge service calls take a dvoid
*
OCI handle as one of the arguments that may be either an environment or a session handle. While most service calls are allowed with either of the handles, certain calls may not be valid with one of the handles. For example, it may be an error to allocate OCI_DURATION_SESSION
with an environment handle. An error will typically be returned in an error handle.
Most of the cartridge service can also be used on the client side code. Refer to individual services for restrictions. To use cartridge service on the client side, the OCI environment has to be initialized with OCI_OBJECT
option. This is automatically effected in a cartridge.
Most of the services listed in this document can be used in developing a database cartridge, but please refer to documentation of each individual service for restrictions. New service calls are available to obtain the session handle in a callout. The session handle is available without opening a connection back to the server.
Before using any service, the OCI environment handle must be initialized. All the services take an OCI environment (or user_session) handle as an argument. Errors are returned in an OCI error handle. The sub handles required for various service calls are not allocated along with the OCI environment handle. Services which need to initialize an environment provide methods to initialize it.
The following example demonstrates the initialization of these handles:
{ OCIEnv *envhp; OCIError *errhp; (void) OCIInitialize(OCI_OBJECT, (dvoid *)0, 0, 0, 0); (void) OCIEnvInit(&envhp, OCI_OBJECT, (size_t)0, (dvoid **)0); (void) OCIHandleAlloc((dvoid *)envhp, (dvoid **)errhp, OCI_HTYPE_ERROR, (size_ t)0, (dvoid **)0); /* ... use the handles ... */ (void) OCIHandleFree((dvoid *)errhp, OCI_HTYPE_ERROR); }
Routines that return errors will generally return OCI_SUCCESS
or OCI_ERROR
. Some routines may return OCI_SUCCESS_WITH_INFO
, OCI_INVALID_HANDLE
, or OCI_NO_DATA
. If OCI_ERROR
or OCI_SUCCESS_WITH_INFO
is returned, then an error code, an error facility, and possibly an error message can be retrieved by calling OCIErrorGet
:
{ OCIError *errhp; ub4 errcode; text buffer[512]; (void) OCIErrorGet((dvoid *)errhp, 1, (text *)NULL, &errcode, buffer, sizeof(buffer), OCI_HTYPE_ERROR); }
|
![]() Copyright © 1996-2000, Oracle Corporation. All Rights Reserved. |
|