Oracle9i Application Developer's Guide - Large Objects (LOBs) Release 1 (9.0.1) Part Number A88879-01 |
|
Migrating From LONGs to LOBs, 6 of 14
Prior to this release, OCI provided interface calls for performing piecewise INSERTS, UPDATES, and fetches of LONG data. These APIs also allow you to provide data dynamically in case of array INSERTs or UPDATEs, instead of providing a static array of bind values. These piecewise operations can be performed by polling or by providing a callback.
The following functions are now supported for LOBs for you to directly INSERT, UPDATE, and fetch LOB data without your having to deal with the LOB locator:
OCIBindByName()
or OCIBindByPos().
These functions create an association between a program variable and a placeholder in the SQL statement or a PL/SQL block for INSERT/UPDATE.
OCIBindDynamic()
. This call is used to register user callbacks for dynamic data allocation for INSERT/UPDATE.
OCIDefineByPos()
. This call associates an item in a SELECT-list with the type and output data buffer.
OCIDefineDynamic()
. This call registers user callbacks for SELECTs if the OCI_DYNAMIC_FETCH mode was selected in OCIDefineByPos()
.
OCIStmtGetPieceInfo()
and OCIStmtSetPieceInfo()
. These calls are used to get or set piece information for piecewise operations.
"Runtime data allocation and piecewise operations" in the Oracle Call Interface Programmer's Guide, for details on the LONG API.
See Also:
The aforementioned OCI functions work in this release for LOBs in exactly the same way as they do for LONGs. Using these, you can perform INSERTs, UPDATEs, and fetches of data as described here.
There are various ways to perform INSERT or UPDATE of LOB data.
Note: These are in addition to the ways to insert LOB locators, which are documented in Chapter 10, "Internal Persistent LOBs". |
In all the ways described in the following, it is assumed that you have initialized the OCI environment and allocated all necessary handles.
To perform simple INSERTs and UPDATEs in one piece, the steps are:
OCIStmtPrepare()
to prepare the statement in OCI_DEFAULT mode.
OCIBindByName()
or OCIBindbyPos()
to bind a placeholder in OCI_DEFAULT mode to bind a LOB as CHAR or BIN.
OCIStmtExecute()
to do the actual INSERT/UPDATE.
To perform piecewise INSERTs and UPDATEs with polling, the steps are:
OCIStmtPrepare()
to prepare the statement in OCI_DEFAULT mode.
OCIBindByName()
or OCIBindbyPos() to bind a placeholder in OCI_DATA_AT_EXEC mode to bind a LOB as CHAR or BIN.
OCIStmtExecute()
in default mode. This should return OCI_NEED_DATA.
To perform piecewise INSERTs and UPDATEs with callback, the steps are:
Use any of the above modes in conjunction with OCIBindArrayOfStruct()
, or by specifying the number of iterations (iter) value > 1 in the OCIStmtExecute()
call.
There are three ways to fetch the LOB data.
Note: These are in addition to the ways to fetch the LOB locator, which are documented in Chapter 10, "Internal Persistent LOBs". |
To perform a simple fetch on LOBs in one piece, the steps involved are:
To perform a piecewise fetch on LOBs with polling, the steps are:
OCIStmtPrepare()
to prepare the SELECT statement in OCI_DEFAULT mode.
OCIDefinebyPos()
to define a select list position in OCI_DYNAMIC_FETCH mode to define a LOB as CHAR or BIN.
OCIStmtExecute()
to execute the SELECT statement.
OCIStmtFetch()
in default mode. This should return OCI_NEED_DATA.
To perform a piecewise fetch on LOBs with callback, the steps are:
Use any of the above modes in conjunction with OCIDefineArrayOfStruct()
, or by specifying the number of iterations (iter) value >1 in the OCIStmtExecute()
call.
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|