Oracle Call Interface Programmer's Guide Release 2 (9.2) Part Number A96584-01 |
|
OCI Navigational and Type Functions, 23 of 36
Creates a standalone instance
sword OCIObjectNew ( OCIEnv *env, OCIError *err, CONST OCISvcCtx *svc, OCITypeCode typecode, OCIType *tdo, dvoid *table, OCIDuration duration, boolean value, dvoid **instance );
The OCI environment handle initialized in object mode with Unicode setting. See the description of OCIEnvCreate()
and OCIInitialize()
for more information.
The OCI error handle. If there is an error, it is recorded in err
and this function returns OCI_ERROR. Obtain diagnostic information by calling OCIErrorGet()
.
OCI service handle. It must be given if the program wants to associate the duration of an instance with an OCI service (for example, free a string when the transaction is committed). This parameter is ignored if the TDO is given.
The typecode of the type of the instance.
Pointer to the type descriptor object. The TDO describes the type of the instance that is to be created. Refer to OCITypeByName()
for obtaining a TDO. The TDO is required for creating a named type, such as an object or a collection.
Pointer to a table object which specifies a table in the server. This
parameter can be set to null if no table is given. See the following description to find out how the table object and the TDO are used together to determine the kind of instances (persistent, transient, value) to be created. Also see OCIObjectPinTable()
for retrieving a table object.
This is an overloaded parameter. The use of this parameter is based on the kind of the instance that is to be created.
Specifies whether the created object is a value. If TRUE
, then a value is created. Otherwise, a referenceable object is created. If the instance is not an object, then this parameter is ignored.
Address of the newly created instance. The instance can be a character string in Unicode if the environment handle has the appropriate setting and the object is OCIString. In this case, the instance will have a flag to indicate its Unicode setting.
This function creates a new instance of the type specified by the typecode or the TDO. It can create an OCIString object with a Unicode buffer if the typecode indicates the object to be created is OCIString.
Based on the parameters typecode
(or tdo
), value
and table
, different instances are created:
Type Created | Not null | Null |
---|---|---|
object type (value= |
value |
value |
object type (value= |
persistent object |
transient object |
built-in type |
value |
value |
collection type |
value |
value |
This function allocates the top-level memory chunk of an instance. The attributes in the top-level memory are initialized which means that an attribute of varchar2 is initialized to a OCIString of 0 length. If the instance is an object, the object is marked existed but is atomically null.
See Also:
For information about creating new objects based on object views or user-created OIDs, see "Creating Objects Based on Object Views or User-defined OIDs". |
The object is marked dirty and existed. The allocation duration for the object is session. The object is pinned and the pin duration is specified by the given parameter duration
. Creating a persistent object does not cause any entries to be made into a database table until the object is flushed to the server.
The object is pinned. The allocation duration and the pin duration are specified by the given parameter duration
.
The allocation duration is specified by the given parameter duration
.
By default, all attributes of a newly created objects have null values. After initializing attribute data, the user must change the corresponding null status of each attribute to non-null.
It is possible to have attributes set to non-null values when an object is created. This is accomplished by setting the OCI_ATTR_OBJECT_NEWNOTNULL attribute of the environment handle to TRUE
using OCIAttrSet()
. This mode can later be turned off by setting the attribute to FALSE
. If OCI_ATTR_OBJECT_NEWNOTNULL is set to TRUE
, then OCIObjectNew()
creates a non-null object.
If the object contains an internal LOB attribute, the LOB is set to empty. The object must be marked as dirty and flushed (in order to insert the object into the table) and repinned before the user can start writing data into the LOB. When pinning the object after creating it, you must use the OCI_PIN_LATEST pin option in order to retrieve the newly updated LOB locator from the server.
If the object contains an external LOB attribute (FILE), the FILE locator is allocated but not initialized. The user must call OCILobFileSetName()
to initialize the FILE attribute before flushing the object to the database. It is an error to INSERT
or UPDATE
a FILE without first indicating a directory alias and filename. Once the filename is set, the user can start reading from the FILE.
|
Copyright © 1996, 2002 Oracle Corporation. All Rights Reserved. |
|