Skip Headers

Oracle Call Interface Programmer's Guide
Release 2 (9.2)

Part Number A96584-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to beginning of chapter Go to next page

OCI Navigational and Type Functions, 23 of 36


OCIObjectNew()

Purpose

Creates a standalone instance

Syntax

sword OCIObjectNew ( OCIEnv            *env, 
                     OCIError          *err, 
                     CONST OCISvcCtx   *svc, 
                     OCITypeCode       typecode,
                     OCIType           *tdo, 
                     dvoid             *table,
                     OCIDuration       duration,
                     boolean           value,
                     dvoid             **instance ); 

Parameters

env (IN/OUT)

The OCI environment handle initialized in object mode with Unicode setting. See the description of OCIEnvCreate() and OCIInitialize() for more information.

err (IN/OUT)

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().

svc (IN) [optional]

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.

typecode (IN)

The typecode of the type of the instance.

See Also:

"Typecodes"

tdo (IN) [optional]

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.

table (IN) [optional]

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.

duration (IN)

This is an overloaded parameter. The use of this parameter is based on the kind of the instance that is to be created.

value (IN)

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.

instance (OUT)

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.

Comments

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.

See Also:

"Typecodes"

Based on the parameters typecode (or tdo), value and table, different instances are created:

Type Created Not null Null

object type (value=TRUE)

value

value

object type (value=FALSE)

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".

For Persistent Objects

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.

For Transient Objects

The object is pinned. The allocation duration and the pin duration are specified by the given parameter duration.

For Values

The allocation duration is specified by the given parameter duration.

Attribute Values of New Objects

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.

See Also:

"Attribute Values of New Objects"

Objects with LOB Attributes

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.


Note:

Oracle now supports only binary FILEs (BFILEs).


Related Functions

OCIObjectPinTable(), OCIObjectFree()


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback