Oracle® Call Interface Programmer's Guide 10g Release 1 (10.1) Part Number B10779-01 |
|
|
View PDF |
This section describes the OCI handle and descriptor functions.
This call is used to get a particular attribute of a handle.
sword OCIAttrGet ( CONST dvoid *trgthndlp, ub4 trghndltyp, dvoid *attributep, ub4 *sizep, ub4 attrtype, OCIError *errhp );
Pointer to a handle type. The actual handle can be a statement handle, a session handle, and so on. When this call is used to get encoding, users are allowed to check against either an environment or statement handle.
The handle type. Valid types are:
Pointer to the storage for an attribute value. Will be in the encoding specified by the charset
parameter of a previous call to OCIEnvNlsCreate()
.
The size of the attribute value, always in bytes because attributep
is a dvoid
pointer. This can be passed as NULL
for most attributes because the sizes of non-string attributes are already known by the OCI library. For text*
parameters, a pointer to a ub4
must be passed in to get the length of the string.
The type of attribute being retrieved. The types are listed in this document at:
See Also:
See Appendix A, "Handle and Descriptor Attributes", for a list of handle types and their readable attributes |
An error handle you can pass to OCIErrorGet()
for diagnostic information in the event of an error.
This call is used to get a particular attribute of a handle. OCI_DTYPE_PARAM is used to do implicit and explicit describes. The parameter descriptor is also used in direct path loading. For implicit describes, the parameter descriptor has the column description for each select list. For explicit describes, the parameter descriptor has the describe information for each schema object we are trying to describe. If the top-level parameter descriptor has an attribute which is itself a descriptor, use OCI_ATTR_PARAM as the attribute type in the subsequent call to OCIAttrGet()
to get the Unicode information in an environment or statement handle.
A function closely related to OCIAttrGet()
is OCIDescribeAny()
, which is a generic describe call that describes existing schema objects: tables, views, synonyms, procedures, functions, packages, sequences, and types. As a result of this call, the describe handle is populated with the object-specific attributes which can be obtained through an OCIAttrGet()
call.
Then an OCIParamGet()
on the describe handle returns a parameter descriptor for a specified position. Parameter positions begin with 1. Calling OCIAttrGet()
on the parameter descriptor returns the specific attributes of a stored procedure or function parameter or a table column descriptor as the case may be. These subsequent calls do not need an extra round trip to the server because the entire schema object description is cached on the client side by OCIDescribeAny()
. Calling OCIAttrGet()
on the describe handle can also return the total number of positions.
In UTF-16 mode, particularly when executing a loop, try to reuse the same pointer variable corresponding to an attribute and copy the contents to local variables after OCIAttrGet()
is called. If multiple pointers are used for the same attribute, a memory leak can occur.
This call is used to set a particular attribute of a handle or a descriptor.
sword OCIAttrSet ( dvoid *trgthndlp, ub4 trghndltyp, dvoid *attributep, ub4 size, ub4 attrtype, OCIError *errhp );
Pointer to a handle type whose attribute gets modified.
The handle type.
Pointer to an attribute value. The attribute value is copied into the target handle. If the attribute value is a pointer, then only the pointer is copied, not the contents of the pointer. String attributes must be in the encoding specified by the charset
parameter of a previous call to OCIEnvNlsCreate()
.
The size of an attribute value. This can be passed in as 0 for most attributes as the size is already known by the OCI library. For text*
attributes, a ub4
must be passed in set to the length of the string in bytes, regardless of encoding.
The type of attribute being set.
An error handle you can pass to OCIErrorGet()
for diagnostic information in the event of an error.
See Appendix A, "Handle and Descriptor Attributes", for a list of handle types and their writable attributes.
Allocates storage to hold descriptors or LOB locators.
sword OCIDescriptorAlloc ( CONST dvoid *parenth, dvoid **descpp, ub4 type, size_t xtramem_sz, dvoid **usrmempp);
An environment handle.
Returns a descriptor or LOB locator of desired type.
Specifies the type of descriptor or LOB locator to be allocated:
OCISnapshot
BLOB
or CLOB
) of C type OCILobLocator
OCILobLocator
.ROWID
descriptor of C type OCIRowid
.ANSI
DATE
descriptor of C type OCIDateTime
TIMESTAMP
descriptor of C type OCIDateTime
TIMESTAMP
WITH
TIME
ZONE
descriptor of C type OCIDateTime
TIMESTAMP
WITH
LOCAL
TIME
ZONE
descriptor of C type OCIDateTime
INTERVAL
YEAR
TO
MONTH
descriptor of C type OCIInterval
INTERVAL
DAY
TO
SECOND
descriptor of C type OCIInterval
OCIComplexObjectComp
.OCIAQEnqOptions
.OCIAQDeqOptions
.OCIAQMsgProperties
.OCIAQAgent
.Specifies an amount of user memory to be allocated for use by the application for the lifetime of the descriptor.
Returns a pointer to the user memory of size xtramem_sz
allocated by the call for the user for the lifetime of the descriptor.
Returns a pointer to an allocated and initialized descriptor, corresponding to the type specified in type
. A non-NULL
descriptor or LOB locator is returned on success. No diagnostics are available on error.
This call returns OCI_SUCCESS if successful, or OCI_INVALID_HANDLE if an out-of-memory error occurs.
See Also:
For more information about the |
Deallocates a previously allocated descriptor.
sword OCIDescriptorFree ( dvoid *descp, ub4 type );
An allocated descriptor.
Specifies the type of storage to be freed. The specific types are:
ROWID
descriptorANSI
DATE
descriptorTIMESTAMP
descriptorTIMESTAMP
WITH
TIME
ZONE
descriptorTIMESTAMP
WITH
LOCAL
TIME
ZONE
descriptorINTERVAL
YEAR
TO
MONTH
descriptorINTERVAL
DAY
TO
SECOND
descriptorThis call frees storage associated with a descriptor. Returns OCI_SUCCESS or OCI_INVALID_HANDLE. All descriptors may be explicitly deallocated, however the OCI will deallocate a descriptor if the environment handle is deallocated.
This call returns a pointer to an allocated and initialized handle.
sword OCIHandleAlloc ( CONST dvoid *parenth, dvoid **hndlpp, ub4 type, size_t xtramem_sz, dvoid **usrmempp );
An environment handle.
Returns a handle.
Specifies the type of handle to be allocated. The allowed types are:
OCIAuthInfo
OCIComplexObject
OCISecurity
OCICPool
OCIDirPathCtx
OCIDirPathColArray
OCIDirPathStream
OCIEnv
OCIError
OCISvcCtx
OCIStmt
OCIDescribe
OCIServer
OCISession
OCITrans
OCISPool
OCISubscription
OCIProcess
Specifies an amount of user memory to be allocated.
Returns a pointer to the user memory of size xtramem_sz
allocated by the call for the user.
Returns a pointer to an allocated and initialized handle, corresponding to the type specified in type
. A non-NULL
handle is returned on success. All handles are allocated with respect to an environment handle which is passed in as a parent handle.
No diagnostics are available on error. This call returns OCI_SUCCESS if successful, or OCI_INVALID_HANDLE if an error occurs.
Handles must be allocated using OCIHandleAlloc()
before they can be passed into an OCI call.
To allocate and initialize an environment handle, call OCIEnvInit()
.
See Also:
For more information about using the |
This call explicitly deallocates a handle.
sword OCIHandleFree ( dvoid *hndlp, ub4 type );
A handle allocated by OCIHandleAlloc()
.
Specifies the type of storage to be freed. The specific types are:
This call frees up storage associated with a handle, corresponding to the type specified in the type
parameter.
This call returns either OCI_SUCCESS or OCI_INVALID_HANDLE.
All handles may be explicitly deallocated. The OCI will deallocate a child handle if the parent is deallocated.
OCIHandleAlloc()
, OCIEnvInit()
Returns a descriptor of a parameter specified by position in the describe handle or statement handle.
sword OCIParamGet ( CONST dvoid *hndlp, ub4 htype, OCIError *errhp, dvoid **parmdpp, ub4 pos );
A statement handle or describe handle. The OCIParamGet()
function will return a parameter descriptor for this handle.
The type of the handle passed in the hndlp
parameter. Valid types are:
An error handle you can pass to OCIErrorGet()
for diagnostic information in the event of an error.
A descriptor of the parameter at the position given in the pos
parameter, of handle type OCI_DTYPE_PARAM.
Position number in the statement handle or describe handle. A parameter descriptor will be returned for this position.
This call returns a descriptor of a parameter specified by position in the describe handle or statement handle. Parameter descriptors are always allocated internally by the OCI library. They can be freed using OCIDescriptorFree()
. For example, if you fetch the same column metadata for every execution of a statement, then the program will leak memory unless you explicitly free the parameter descriptor between each call to OCIParamGet()
.
See Also:
See Appendix A, "Handle and Descriptor Attributes", for more detailed information about parameter descriptor attributes. |
OCIAttrGet(), OCIAttrSet(), OCIParamSet(), OCIDescriptorFree()
Used to set a complex object retrieval (COR) descriptor into a COR handle.
sword OCIParamSet ( dvoid *hndlp, ub4 htype, OCIError *errhp, CONST dvoid *dscp, ub4 dtyp, ub4 pos );
Handle pointer.
Handle type.
An error handle you can pass to OCIErrorGet()
for diagnostic information in the event of an error.
Complex object retrieval descriptor pointer.
Descriptor type. The descriptor type for a COR descriptor is OCI_DTYPE_COMPLEXOBJECTCOMP.
Position number.
The COR handle must have been previously allocated using OCIHandleAlloc()
, and the descriptor must have been previously allocated using OCIDescriptorAlloc()
. Attributes of the descriptor are set using OCIAttrSet()
.
See Also:
For more information about complex object retrieval, see "Complex Object Retrieval". |