Oracle9i Application Developer's Guide - Large Objects (LOBs)
Release 1 (9.0.1)

Part Number A88879-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

LOB Support in Different Programmatic Environments, 6 of 11


Using C++ (OCCI) To Work With LOBs

Oracle C++ Call Interface (OCCI) is a C++ API for manipulating data in an Oracle database. OCCI is organized as an easy-to-use collection of C++ classes which enable a C++ program to connect to a database, execute SQL statements, insert/update values in database tables, retrieve results of a query, execute stored procedures in the database, and access metadata of database schema objects. OCCI also provides a seamless interface to manipulate objects of user-defined types as C++ class instances.

Oracle C++ Call Interface (OCCI) is designed so that you can use OCI and OCCI together to build applications.

The OCCI API provides the following advantages over JDBC and ODBC:

You can use Oracle C++ Call Interface (OCCI) to make changes to an entire internal LOB, or to pieces of the beginning, middle, or end of it, as follows:

Distinct Classes for Each LOB Type

Unlike OCI which uses a common API for operations on BLOBs, CLOBs, and BFILEs, OCCI has distinct classes for each LOB types, as follows:

OCCIClob Class

The OCCIClob driver implements a CLOB object using an SQL locator(CLOB). This means that a CLOB object contains a logical pointer to the SQL CLOB data rather than the data itself.

The CLOB interface provides methods for getting the length of an SQL CLOB (Character Large Object) value, for materializing a CLOB value on the client, and getting a substring. Methods in the interfaces ResultSet statement such as getClob() and setClob() allow you to access SQL CLOB values.

OCCIBlob Class

Methods in the OCCIResultSet and OCCIStatement interfaces, such as getBlob() and setBlob(), allow you to access SQL BLOB values. The OCCIBlob interface provides methods for getting the length of a SQL BLOB value, for materializing a BLOB value on the client, and for extracting a part of the BLOB.

These methods are listed in the tables below.

See Also:

 

Offset and Amount Parameters: Fixed-Width Versus Varying-Width, Character or Byte With OCCI

Fixed Width Character Set Rules

In OCCI, for fixed-width client-side character sets, the following rules apply:

Varying-Width Character Set Rules

The following rules apply only to varying-width client-side character sets:

OffSet and Amount Parameters for Other OCCI Operations

For all other OCCI LOB operations, irrespective of the client-side character set, the amount parameter is in characters for CLOBs and NCLOBs. These include the following:

All these operations refer to the amount of LOB data on the server.

See also:

Oracle9i Globalization and National Language Support Guide 

NCLOBs

Loading from Files with OCCIClob.copy() and OCCIBlob.copy(): Specify the Amount Parameter to be Less than Length of BFILE

The LoadFromFile functionality in OCCI is provided though the OCCIClob.copy() and OCCIBlob.copy() methods. These take an OCCIBfile argument.

You cannot specify amounts larger than the length of the BFILE.

OCCIClob.read(), OCCIBlob.read(), and OCCIBfile.read(): Specify Amount Parameter to be 4 gigabytes - 1

When reading in OCCIClobs, OCCIBlobs, and OCCIBfiles, specify the amount = 4 gigabytes-1, and it will read to the end of the LOB.

Further Information About OCCI

See Also:

 

OCCI Methods that Operate on BLOBs, BLOBs, NCLOBs, and BFILEs

OCCI methods that operate on BLOBs, CLOBs, NCLOBs, and BFILEs are as follows:

OCCI Methods To Modify Internal LOB (BLOB, CLOB, and NCLOB) Values

Table 3-16 OCCI Clob and OCCIBlob Methods To Modify Internal LOB (BLOB, CLOB, and NCLOB) Values
Function/Procedure  Description 

OCCIBlob.append() 

Appends CLOB or BLOB value to another LOB

OCCIBlob.copy()  

Copies all or part of a CLOB or BLOB to another LOB

OCCIBlob.copy() 

Loads BFILE data into an internal LOB. 

OCCIBlob.trim()  

Truncates a CLOB or BLOB

OCCIBlob.write()  

Writes data from a buffer into a LOB, overwriting existing data

OCCI Methods To Read or Examine Internal LOB and BFILE Values

Table 3-17 OCCI Blob/OCCIClob/OCCIBfile Methods To Read or Examine internal LOB and external LOB (BFILE) Values
Function/Procedure  Description 

OCCIBlob.getChunkSize() 

Gets the Chunk size used when reading and writing. This works on internal LOBs and does not apply to external LOBs (BFILEs). 

OCCIBlob.length()  

Returns the length of a LOB or a BFILE

OCCIBlob.read()  

Reads a specified portion of a non-null LOB or a BFILE into a buffer. 

OCCI Read-Only Methods For BFILEs

Table 3-18  OCCI Read-Only Methods For BFILES
Function/Procedure  Description 

OCCIBfile.close() 

Closes an open BFILE

OCCIBfile.fileExists() 

Checks whether a BFILE exists. 

OCCIBfile.getFileName()  

Returns the name of a BFILE

OCCIBfile.getDirAlias() 

Gets the directory alias. 

OCCIBfile.isOpen() 

Checks whether a BFILE is open. 

OCCIBfile.open() 

Opens a BFILE

Other OCCI LOB Methods

Table 3-19  Other OCCI LOB Methods
Methods  Description 

OCCIClob/Blob/Bfile.=  

Assigns one LOB locator to another. Use = or the copy constructor. 

OCCIClob.getCharSetForm()  

Returns the character set form of a LOB

OCCIClob.getCharSetId() 

Returns the character set ID of a LOB

OCCIBfile.setName()  

Sets the name of a BFILE

OCCIClob/Blob/Bfile.IsEqual() 

Checks whether two LOB refer to the same LOB.  

OCCIClob/Blob/Bfile.isInitialized()  

Checks whether a LOB is initialized.  

OCCI Methods To Open and Close Internal and External LOBs

Table 3-20  OCCI Methods To Open and Close Internal and External LOBs
Function/Procedure  Description 

OCCIClob/Blob/Bfile.Open() 

Opens a LOB 

OCCIClob/Blob/Bfile.IsOpen() 

Sees if a LOB is open 

OCCIClob/Blob/Bfile.Close()  

Closes a LOB  


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 1996-2001, 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