|Oracle Call Interface Programmer's Guide
Part Number A89857-01
More OCI Relational Functions, 31 of 97
Opens a LOB, internal or external, in the indicated mode.
The service context handle.
An error handle you can pass to
OCIErrorGet() for diagnostic information in the event of an error.
The LOB to open. The locator can refer to an internal or external LOB.
The mode in which to open the LOB/
BFILE. In Oracle8i or later, valid modes for LOBs are OCI_LOB_READONLY and OCI_LOB_READWRITE. Note that OCI_FILE_READONLY exists as input to
OCILobFileOpen(). OCI_FILE_READONLY can be used with
OCILobOpen() if the input locator is for a
It is an error to open the same LOB twice.
BFILEs cannot be opened in read-write mode. Note that if the LOB/
BFILE was opened in read-only mode and the user tries to write to the LOB/
BFILE, an error will be returned.
Opening a LOB requires a round- trip to the server for both internal and external LOBs. For internal LOBs, the open will trigger other code that relies on the open call. For external LOBs (
BFILEs), open requires a round- trip because the actual operating system file on the server side is being opened.
It is not necessary to open a LOB in order to perform operations on it. When using functional indexes, extensible indexes or context, and making more than one call to update or write to the LOB, you should first call
OCILobOpen(), then update the LOB as many times as you want, and finally call
OCILobClose(). This sequence
of operations will ensure that the indexes are only updated once at the end of all the write operations instead of once per write operation.
It is not mandatory that you wrap all LOB operations inside the Open/Close calls. However, if you open a LOB, then you must close it before you commit or rollback your transaction. When an internal LOB is closed, it updates the functional and domain indexes on the LOB column. It is an error to commit the transaction before closing all opened LOBs that were opened by the transaction.
When the error is returned, the LOB is no longer marked as open, but the transaction is successfully committed. Hence, all the changes made to the LOB and non-LOB data in the transaction are committed but the domain and functional indexing are not updated. If this happens, please rebuild your functional and domain indexes on the LOB column.
If you do not wrap your LOB operations inside the Open/Close API, then the functional and domain indexes are updated each time you write to the LOB. This can adversely affect performance, so if you have functional or domain indexes, we recommend that you enclose write operations to the LOB within the open/close statements.