13.9 Clob Class
The Clob
class defines the common properties of objects of type CLOB
. A Clob
is a large character object stored as a column value in a row of a database table. A Clob
object contains a logical pointer to a CLOB
, not the CLOB
itself.
Methods of the Clob
class enable you to perform specific tasks related to Clob
objects, including methods for getting the length of a SQL CLOB
, for materializing a CLOB
on the client, and for extracting a part of the CLOB
.
The only methods valid on a NULL
CLOB
object are setName(), isNull(), and operator=().
Methods in the ResultSet
and Statement
classes, such as getClob()
and setClob()
, enable you to access an SQL CLOB
value.
An uninitialized CLOB
object can be initialized by:
-
The setEmpty() method. The
CLOB
can then be modified by inserting thisCLOB
into the table and retrieving it usingSELECT...FOR UPDATE
. The write() method modifies theCLOB
; however, the modified data is flushed to the table only when the transaction is committed. Note that aninsert
is not required. -
Assigning an initialized
Clob
object to it.
See Also:
-
In-depth discussion of
LOB
s in the introductory chapter of Oracle Database SecureFiles and Large Objects Developer's Guide,
Table 13-10 Summary of Clob Methods
Method | Summary |
---|---|
|
|
Appends a |
|
Closes a previously opened |
|
Closes the |
|
Copies all or a portion of a |
|
Returns the character set form of the |
|
Returns the character set ID of the |
|
Retrieves the characterset name associated with the |
|
Returns the smallest data size to perform efficient writes to the |
|
Returns the content type of the |
|
Returns the |
|
Returns data from the |
|
Tests whether the |
|
Tests whether the |
|
Tests whether the |
|
Returns the number of characters in the current |
|
Opens the |
|
Assigns a |
|
Tests whether two |
|
Tests whether two |
|
Reads a portion of the |
|
Sets the character set ID associated with the |
|
Sets the character set ID associated with the |
|
Sets the character set form associated with the |
|
Sets the content type of the |
|
Sets the |
|
Sets the |
|
Specifies a |
|
Truncates the |
|
Writes a buffer into an unopened |
|
Writes a buffer into an open |
13.9.1 Clob()
Clob
class constructor.
Syntax | Description |
---|---|
Clob(); |
Creates a |
Clob( const Connection *connectionp); |
Creates an uninitialized |
Clob( const Clob *srcClob); |
Creates a copy of a |
Parameter | Description |
---|---|
connectionp |
Connection pointer |
srcClob |
The source |
13.9.2 append()
Appends a CLOB
to the end of the current CLOB
.
Syntax
void append( const Clob &srcClob);
Parameter | Description |
---|---|
srcClob |
The |
13.9.4 closeStream()
Closes the Stream
object obtained from the CLOB
.
Syntax
void closeStream( Stream *stream);
Parameter | Description |
---|---|
stream |
The Stream object to be closed. |
13.9.5 copy()
Copies a part or all of a BFILE
or CLOB
into the current CLOB
.
OCCI does not perform any characterset conversions when loading data from a Bfile
into a Clob
; therefore, ensure that the contents of the Bfile
are character data in the server's Clob
storage characterset.
Syntax | Description |
---|---|
void copy( const Bfile &srcBfile, unsigned int numBytes, unsigned int dstOffset = 1, unsigned int srcOffset = 1); |
Copies a |
void copy( const Clob &srcClob, unsigned int numBytes, unsigned int dstOffset = 1, unsigned int srcOffset = 1); |
Copies a If the destination |
Parameter | Description |
---|---|
srcBfile |
The |
srcClob |
The |
numBytes |
The number of bytes to be copied from the source |
dstOffset |
The starting position at which data is to be is at 0. The starting position at which to begin writing data into the current |
srcOffset |
The starting position at which to begin reading data from the source |
13.9.6 getCharSetForm()
Returns the character set form of the CLOB
.
Syntax
CharSetForm getCharSetForm() const;
13.9.7 getCharSetId()
Returns the character set ID of the CLOB
, in string form.
Syntax
string getCharSetId() const;
13.9.8 getCharSetIdUString()
Retrieves the characterset name associated with the Clob
; UString
version.
Syntax
UString getCharSetIdUString() const;
13.9.9 getChunkSize()
Returns the smallest data size to perform efficient writes to the CLOB
.
Syntax
unsigned int getChunkSize() const;
13.9.10 getContentType()
Returns the content type of the Clob
. If a content type has not been assigned, returns a NULL
string.
Syntax
string getContentType();
13.9.11 getOptions()
Returns the CLOB
's LobOptionValue
for a specified LobOptionType
.
Throws an exception if attempting to retrieve a value for an option that is not configured on the database column or partition that stores the CLOB
.
Syntax
LobOptionValue getOptions( LobOptionType optType);
13.9.12 getStream()
Returns a Stream
object from the CLOB
. If a stream is open, it is disallowed to open another stream on CLOB
object, so the user must always close the stream before performing any Clob
object operations. The client's character set id and form is used by default, unless they are explicitly set through setCharSetId() and setEmpty() calls.
Syntax
Stream* getStream( unsigned int offset = 1, unsigned int amount = 0);
Parameter | Description |
---|---|
offset |
The starting position at which to begin reading data from the |
amount |
The total number of consecutive characters to be read. If |
13.9.13 isInitialized()
Tests whether the Clob object
is initialized. If the Clob
object is initialized, TRUE
is returned; otherwise, FALSE
is returned.
Syntax
bool isInitialized() const;
13.9.14 isNull()
Tests whether the Clob
object is atomically NULL
. If the Clob
object is atomically NULL
, TRUE
is returned; otherwise, FALSE
is returned.
Syntax
bool isNull() const;
13.9.15 isOpen()
Tests whether the CLOB
is open. If the CLOB
is open, TRUE
is returned; otherwise, FALSE
is returned.
Syntax
bool isOpen() const;
13.9.17 open()
Opens the CLOB
in read/write
or read-only mode.
Syntax
void open( LObOpenMode mode = OCCI_LOB_READWRITE);
Parameter | Description |
---|---|
mode |
|
13.9.18 operator=()
Assigns a CLOB
to the current CLOB
. The source CLOB
gets copied to the destination CLOB
only when the destination CLOB
gets stored in the table.
Syntax
Clob& operator=( const Clob &srcClob);
Parameter | Description |
---|---|
srcClob |
The |
13.9.19 operator==()
Compares two Clob
objects for equality. Two Clob
objects are equal if they both refer to the same CLOB
. Two NULL
Clob
objects are not considered equal. If the Blob
objects are equal, then TRUE
is returned; otherwise, FALSE
is returned.
Syntax
bool operator==( const Clob &srcClob) const;
Parameter | Description |
---|---|
srcClob |
The |
13.9.20 operator!=()
Compares two Clob objects
for inequality. Two Clob
objects are equal if they both refer to the same CLOB
. Two NULL
Clob
objects are not considered equal. If the Clob
objects are not equal, then TRUE
is returned; otherwise, FALSE
is returned.
Syntax
bool operator!=( const Clob &srcClob) const;
Parameter | Description |
---|---|
srcClob |
The |
13.9.21 read()
Reads a part or all of the CLOB
into a buffer.
Returns the actual number of characters read for fixed-width charactersets, such as UTF16, or the number of bytes read for multibyte charactersets, including UTF8.
The client's character set id and form is used by default, unless they are explicitly set through setCharSetId(), setCharSetIdUString() and setCharSetForm() calls.
Note that for the second version of the method, the return value represents either the number of characters read for fixed-width charactersets (UTF16), or the number of bytes read for multibyte charactersets (including UTF8).
Syntax | Description |
---|---|
unsigned int read( unsigned int amt, unsigned char *buffer, unsigned int bufsize, unsigned int offset=1) const; |
Reads a part or all of the |
unsigned int read( unsigned int amt, unsigned utext *buffer, unsigned int bufsize, unsigned int offset=1) const; |
Reads a part or all of the |
Parameter | Description |
---|---|
amt |
The number of bytes to be read. from the |
buffer |
The buffer that the |
buffsize |
The size of the buffer. Valid values are numbers greater than or equal to |
offset |
The starting position at which to begin reading data from the |
13.9.22 setCharSetId()
Sets the Character set Id associated with Clob
. The characterset id set is used for read/write and getStream() operations. If no value is set explicitly, the default client's character set id is used. List of character sets supported is given in Globalization Support Guide Appendix A.
Syntax
void setCharSetId( const string &charset);
Parameter | Description |
---|---|
charset |
Oracle supported characterset name, such as |
13.9.23 setCharSetIdUString()
Sets the characterset id associated with Clob
; used when the environment's characterset is UTF16
. The charset
id set is used for read, write and getStream() operations.
Syntax
void setCharSetIdUSString( const string &charset);
Parameter | Description |
---|---|
charset |
Oracle supported characterset name, such as |
13.9.24 setCharSetForm()
Sets the character set form associated with the CLOB
. The charset form set is used for read, write and getStream() operations. If no value is set explicitly, by default, OCCI_SQLCS_IMPLICIT
is used.
Syntax
void setCharSetForm( CharSetForm csfrm );
Parameter | Description |
---|---|
csfrm |
The charset form for |
13.9.25 setContentType()
Sets the content type of the Clob
. If the Clob
is not a SecureFile, throws an exception.
Syntax
void setContentType( const string contenttype);
Parameter | Description |
---|---|
contenttype |
The content type of the |
13.9.26 setEmpty()
Sets the Clob
object to empty.
Syntax | Description |
---|---|
void setEmpty(); |
Sets the |
void setEmpty( const Connection* connectionp); |
Sets the |
Parameter | Description |
---|---|
connectionp |
The new connection pointer for the |
13.9.28 setOptions()
Specifies a LobOptionValue
for a particular LobOptionType
. Enables advanced compression, encryption and deduplication of CLOBs. See Table 7-1 and Table 7-2.
Throws an exception if attempting to set or un-set an option that is not configured on the database column or partition that stores the CLOB
.
Throws an exception if attempting to turn off encryption in an encrypted CLOB
column.
Syntax
void setOptions( LobOptionType optType, LobOptionValue optValue);
Parameter | Description |
---|---|
optType |
The |
optValue |
The |
13.9.29 trim()
Truncates the CLOB
to the new length specified.
Syntax
void trim( unsigned int newlen);
Parameter | Description |
---|---|
newlen |
The new length of the |
13.9.30 write()
Writes data from a buffer into a CLOB
.
This method implicitly opens the CLOB
, copies the buffer into the CLOB
, and implicitly closes the CLOB
. If the CLOB
is open, use writeChunk() instead. The actual number of characters written is returned. The client's character set id and form is used by default, unless they are explicitly set through setCharSetId() and setCharSetForm() calls.
Syntax | Description |
---|---|
unsigned int write( unsigned int amt, unsigned char *buffer, unsigned int bufsize, unsigned int offset=1); |
Writes data from a buffer into a |
unsigned int write( unsigned int amt, utext *buffer, unsigned int bufsize, unsigned int offset=1); |
Writes data from a UTF16 buffer into a |
Parameter | Description |
---|---|
amt |
The amount parameter represents:
|
buffer |
The buffer containing the data to be written to the |
buffsize |
The size of the buffer containing the data to be written to the |
offset |
The starting position at which to begin writing data into the |
13.9.31 writeChunk()
Writes data from a buffer into a previously opened CLOB
. Returns the actual number of characters. The client's character set id and form is used by default, unless they are explicitly set through setCharSetId() and setCharSetForm() calls.
Syntax | Description |
---|---|
unsigned int writeChunk( unsigned int amt, unsigned char *buffer, unsigned int bufsize, unsigned int offset=1); |
Writes data from a buffer into a previously opened |
unsigned int writeChunk( unsigned int amt, utext *buffer, unsigned int bufsize, unsigned int offset=1); |
Writes data from a UTF16 buffer into a |
Parameter | Description |
---|---|
amt |
The amount parameter represents either a number of characters written for fixed-width charactersets (UTF16) or a number of bytes written for multibyte charactersets (including UTF8) |
buffer |
The buffer containing the data to be written to the |
buffsize |
The size of the buffer containing the data to be written to the |
offset |
The starting position at which to begin writing data into the |