An OracleClob is an object that has a reference to CLOB data. It provides methods for performing operations on CLOBs.
Note:
TheOracleClob object uses the client side character set when retrieving or writing CLOB data using a .NET Framework byte array.System.Object
System.MarshalByRefObject
System.IO.Stream
Oracle.DataAccess.Types.OracleClob
// C# public sealed class OracleClob : Stream, ICloneable, INullable
All public static methods are thread-safe, although instance methods do not guarantee thread safety.
// C#
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
class OracleClobSample
{
static void Main()
{
string constr = "User Id=scott;Password=tiger;Data Source=oracle";
OracleConnection con = new OracleConnection(constr);
con.Open();
OracleClob clob = new OracleClob(con);
// Write 4 chars from writeBuffer, starting at buffer offset 0
char[] writeBuffer = new char[4] {'a', 'b', 'c', 'd'};
clob.Write(writeBuffer, 0, 4);
// Append first 2 chars from writeBuffer {'a', 'b'} to the oracleClob
clob.Append(writeBuffer, 0, 2);
// Prints "clob.Length = 12"
Console.WriteLine("clob.Length = " + clob.Length);
// Reset the Position for the Read
clob.Position = 0;
// Read 6 chars into readBuffer, starting at buffer offset 0
char[] readBuffer = new char[6];
int charsRead = clob.Read(readBuffer, 0, 6);
// Prints "charsRead = 6"
Console.WriteLine("charsRead = " + charsRead);
// Prints "readBuffer = abcdab"
Console.Write("readBuffer = ");
for(int index = 0; index < readBuffer.Length; index++)
{
Console.Write(readBuffer[index]);
}
Console.WriteLine();
// Search for the 2nd occurrence of a char pattern 'ab'
// starting from char offset 0 in the OracleClob
char[] pattern = new char[2] {'a', 'b'};
long posFound = clob.Search(pattern, 0, 2);
// Prints "posFound = 5"
Console.WriteLine("posFound = " + posFound);
// Erase 4 chars of data starting at char offset 1
// Sets chars to ''
clob.Erase(1, 4);
//Prints "clob.Value = a b"
Console.WriteLine("clob.Value = " + clob.Value);
clob.Close();
clob.Dispose();
con.Close();
con.Dispose();
}
}
Namespace: Oracle.DataAccess.Types
Assembly: Oracle.DataAccess.dll
ODP.NET Version: ODP.NET for .NET Framework 2.0 or ODP.NET for .NET Framework 4
See Also:
OracleClob members are listed in the following tables.
OracleClob constructors are listed in Table 13-19.
Table 13-19 OracleClob Constructors
| Constructor | Description |
|---|---|
|
Creates an instance of the |
OracleClob static fields are listed in Table 13-20.
Table 13-20 OracleClob Static Fields
| Field | Description |
|---|---|
|
Holds the maximum number of bytes a |
|
|
Represents a null value that can be assigned to the value of an |
OracleClob static methods are listed in Table 13-21.
Table 13-21 OracleClob Static Methods
| Methods | Description |
|---|---|
|
|
Inherited from |
OracleClob Instance Properties
OracleClob instance properties are listed in Table 13-22.
Table 13-22 OracleClob Instance Properties
| Properties | Description |
|---|---|
|
Indicates whether or not the LOB stream can be read |
|
|
Indicates whether or not forward and backward seek operations can be performed |
|
|
Indicates whether or not the LOB stream can be written |
|
|
Indicates the |
|
|
Indicates whether the |
|
|
Indicates whether or not the |
|
|
Indicates whether or not the |
|
|
Indicates whether or not the current instance has a null value |
|
|
Indicates whether or not the current instance is bound to a temporary |
|
|
Indicates the size of the |
|
|
Indicates the minimum number of bytes to retrieve or send from the database during a read or write operation |
|
|
Indicates the current read or write position in the LOB stream in bytes |
|
|
Returns the data, starting from the first character in the |
The OracleClob instance methods are listed in Table 13-23.
Table 13-23 OracleClob Instance Methods
| Methods | Description |
|---|---|
|
Appends data to the current |
|
|
Opens the |
|
|
|
Inherited from |
|
|
Inherited from |
|
Creates a copy of an |
|
|
Closes the current stream and releases resources associated with it |
|
|
Compares data referenced by the current instance to that of the supplied object |
|
|
Copies the data to an |
|
|
|
Inherited from |
|
Releases resources allocated by this object |
|
|
Closes the |
|
|
|
Inherited from |
|
|
Inherited from |
|
|
Inherited from |
|
Erases the specified |
|
|
|
Not supported |
|
Returns a hash code for the current instance |
|
|
|
Inherited from |
|
|
Inherited from |
|
|
Inherited from |
|
Compares the LOB data referenced by two |
|
|
Reads from the current instance (Overloaded) |
|
|
|
Inherited from |
|
Searches for a character pattern in the current instance of |
|
|
Sets the position in the current LOB stream |
|
|
Trims or truncates the |
|
|
|
Inherited from |
|
Writes the provided |
|
|
|
Inherited from |
OracleClob constructors create instances of the OracleClob class bound to a temporary CLOB.
This constructor creates an instance of the OracleClob class bound to a temporary CLOB with an OracleConnection object.
OracleClob(OracleConnection, bool, bool)
This constructor creates an instance of the OracleClob class that is bound to a temporary CLOB, with an OracleConnection object, a boolean value for caching, and a boolean value for NCLOB.
This constructor creates an instance of the OracleClob class bound to a temporary CLOB with an OracleConnection object.
// C#
public OracleClob(OracleConnection con);
con
The OracleConnection object.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
The connection must be opened explicitly by the application. OracleClob does not open the connection implicitly. The temporary CLOB utilizes the provided connection to store CLOB data. Caching is not enabled by default.
This constructor creates an instance of the OracleClob class that is bound to a temporary CLOB, with an OracleConnection object, a boolean value for caching, and a boolean value for NCLOB.
// C# public OracleClob(OracleConnection con, bool bCaching, bool bNCLOB);
con
The OracleConnection object connection.
bCaching
A flag that indicates whether or not server-side caching is enabled.
bNCLOB
A flag that is set to true if the instance is a NCLOB or false if it is a CLOB.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
The connection must be opened explicitly by the application. OracleClob does not open the connection implicitly. The temporary CLOB or NCLOB uses the provided connection to store CLOB data.
OracleClob static fields are listed in Table 13-24.
Table 13-24 OracleClob Static Fields
| Field | Description |
|---|---|
|
Holds the maximum number of bytes a |
|
|
Represents a null value that can be assigned to the value of an |
The MaxSize field holds the maximum number of bytes a CLOB can hold, which is 4,294,967,295 (2^32 - 1) bytes.
// C# public static readonly Int64 MaxSize = 4294967295;
This field is useful in code that checks whether or not your operation exceeds the maximum length (in bytes) allowed.
OracleClob static methods are listed in Table 13-25.
OracleClob instance properties are listed in Table 13-26.
Table 13-26 OracleClob Instance Properties
| Properties | Description |
|---|---|
|
Indicates whether or not the LOB stream can be read |
|
|
Indicates whether or not forward and backward seek operations can be performed |
|
|
Indicates whether or not the LOB stream can be written |
|
|
Indicates the |
|
|
Indicates whether the |
|
|
Indicates whether or not the |
|
|
Indicates whether or not the |
|
|
Indicates whether or not the current instance has a null value |
|
|
Indicates whether or not the current instance is bound to a temporary |
|
|
Indicates the size of the |
|
|
Indicates the minimum number of bytes to retrieve or send from the database during a read or write operation |
|
|
Indicates the current read or write position in the LOB stream in bytes |
|
|
Returns the data, starting from the first character in the |
Overrides Stream
This instance property indicates whether or not the LOB stream can be read.
// C#
public override bool CanRead{get;}
If the LOB stream can be read, returns true; otherwise, returns false.
Overrides Stream
This instance property indicates whether or not forward and backward seek operations can be performed.
// C#
public override bool CanSeek{get;}
If forward and backward seek operations can be performed, returns true; otherwise, returns false.
Overrides Stream
This instance property indicates whether or not the LOB object supports writing.
// C#
public override bool CanWrite{get;}
If the LOB stream can be written, returns true; otherwise, returns false.
This instance property indicates the OracleConnection that is used to retrieve and write CLOB data.
// C#
public OracleConnection Connection {get;}
An OracleConnection.
ObjectDisposedException - The object is already disposed.
This instance property indicates whether the CLOB is empty or not.
// C#
public bool IsEmpty {get;}
A bool.
ObjectDisposedException - The object is already disposed.
This instance property indicates whether or not the CLOB has been opened to defer index updates.
// C#
public bool IsInChunkWriteMode{get;}
If the CLOB has been opened, returns true; otherwise, returns false.
This instance property indicates whether or not the OracleClob object represents an NCLOB.
// C#
public bool IsNCLOB {get;}
A bool.
This property indicates whether or not the current instance has a null value.
// C#
public bool IsNull{get;}
Returns true if the current instance has a null value; otherwise, returns false.
This instance property indicates whether or not the current instance is bound to a temporary CLOB.
// C#
public bool IsTemporary {get;}
A bool.
Overrides Stream
This instance property indicates the size of the CLOB data in bytes.
// C#
public override Int64 Length {get;}
An Int64 that indicates the size of the CLOB in bytes.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
This instance property indicates the minimum number of bytes to retrieve or send from the database during a read or write operation.
// C#
public int OptimumChunkSize{get;}
A number representing the minimum bytes to retrieve or send.
ObjectDisposedException - The object is already disposed.
Overrides Stream
This instance property indicates the current read or write position in the LOB stream in bytes.
// C#
public override Int64 Position{get; set;}
An Int64 that indicates the read or write position.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
ArgumentOutOfRangeException - The Position is less than 0.
This instance property returns the data, starting from the first character in the CLOB or NCLOB, as a string.
// C#
public string Value{get;}
A string.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
ArgumentOutOfRangeException - The Value is less than 0.
The value of Position is neither used nor changed by using this property.
The maximum string length that can be returned by this property is 2 GB.
The OracleClob instance methods are listed in Table 13-27.
Table 13-27 OracleClob Instance Methods
| Methods | Description |
|---|---|
|
Appends data to the current |
|
|
Opens the |
|
|
|
Inherited from |
|
|
Inherited from |
|
Creates a copy of an |
|
|
Closes the current stream and releases resources associated with it |
|
|
Compares data referenced by the current instance to that of the supplied object |
|
|
Copies the data to an |
|
|
|
Inherited from |
|
Releases resources allocated by this object |
|
|
Closes the |
|
|
|
Inherited from |
|
|
Inherited from |
|
|
Inherited from |
|
Erases the specified |
|
|
|
Not supported |
|
Returns a hash code for the current instance |
|
|
|
Inherited from |
|
|
Inherited from |
|
|
Inherited from |
|
Compares the LOB data referenced by two |
|
|
Reads from the current instance (Overloaded) |
|
|
|
Inherited from |
|
Searches for a character pattern in the current instance of |
|
|
Sets the position in the current LOB stream |
|
|
Trims or truncates the |
|
|
|
Inherited from |
|
Writes the provided |
|
|
|
Inherited from |
This instance method appends data to the current OracleClob instance.
This instance method appends the CLOB data referenced by the provided OracleClob object to the current OracleClob instance.
This instance method appends data at the end of the CLOB, from the supplied byte array buffer, starting from offset (in bytes) of the supplied byte array buffer.
This instance method appends data from the supplied character array buffer to the end of the current OracleClob instance, starting at the offset (in characters) of the supplied character buffer.
This instance method appends the CLOB data referenced by the provided OracleClob object to the current OracleClob instance.
// C#
public void Append(OracleClob obj);
obj
An OracleClob object.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The parameter has a different connection than the object, OracleConnection is not opened, or OracleConnection has been reopened.
No character set conversions are made.
The provided object and the current instance must be using the same connection; that is, the same OracleConnection object.
This instance method appends data at the end of the CLOB, from the supplied byte array buffer, starting from offset (in bytes) of the supplied byte array buffer.
// C# public int Append(byte[] buffer, int offset, int count);
buffer
An array of bytes, representing a Unicode string.
offset
The zero-based byte offset in the buffer from which data is read.
count
The number of bytes to be appended.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
ArgumentOutOfRangeException - Either the offset or the count parameter is not even.
Both offset and count must be even numbers for CLOB and NCLOB because every two bytes represent a Unicode character.
This instance method appends data from the supplied character array buffer to the end of the current OracleClob instance, starting at the offset (in characters) of the supplied character buffer.
// C# public void Append(char[] buffer, int offset, int count);
buffer
An array of characters.
offset
The zero-based offset (in characters) in the buffer from which data is read.
count
The number of characters to be appended.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
// C#
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
class AppendSample
{
static void Main()
{
string constr = "User Id=scott;Password=tiger;Data Source=oracle";
OracleConnection con = new OracleConnection(constr);
con.Open();
OracleClob clob = new OracleClob(con);
// Append 2 chars {'d', 'e'} to the OracleClob
char[] buffer = new char[3] {'d', 'e', 'f'};
clob.Append(buffer, 0, 2);
// Prints "clob.Value = de"
Console.WriteLine("clob.Value = " + clob.Value);
clob.Close();
clob.Dispose();
con.Close();
con.Dispose();
}
}
This instance method opens the CLOB.
// C# public void BeginChunkWrite();
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
BeginChunkWrite does not need to be called before manipulating the CLOB data. This is provided for performance reasons.
After this method is called, write operations do not cause the domain or function-based index on the column to be updated. Index updates occur only once after EndChunkWrite is called.
This instance method creates a copy of an OracleClob object.
// C# public object Clone();
An OracleClob object.
ICloneable
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
The cloned object has the same property values as that of the object being cloned.
// C#
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
class CloneSample
{
static void Main()
{
string constr = "User Id=scott;Password=tiger;Data Source=oracle";
OracleConnection con = new OracleConnection(constr);
con.Open();
OracleClob clob1 = new OracleClob(con);
// Prints "clob1.Position = 0"
Console.WriteLine("clob1.Position = " + clob1.Position);
// Set the Position before calling Clone()
clob1.Position = 1;
// Clone the OracleClob
OracleClob clob2 = (OracleClob)clob1.Clone();
// Prints "clob2.Position = 1"
Console.WriteLine("clob2.Position = " + clob2.Position);
clob1.Close();
clob1.Dispose();
clob2.Close();
clob2.Dispose();
con.Close();
con.Dispose();
}
}
Overrides Stream
This instance method closes the current stream and releases resources associated with it.
// C# public override void Close();
This instance method compares data referenced by the current instance to that of the supplied object.
// C# public int Compare(Int64 src_offset, OracleClob obj, Int64 dst_offset, Int64 amount);
src_offset
The comparison starting point (in characters) for the current instance.
obj
The provided OracleClob object.
dst_offset
The comparison starting point (in characters) for the provided OracleClob.
amount
The number of characters to compare.
The method returns a value that is:
Less than zero: if the data referenced by the current instance is less than that of the supplied instance.
Zero: if both objects reference the same data.
Greater than zero: if the data referenced by the current instance is greater than that of the supplied instance.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The parameter has a different connection than the object, OracleConnection is not opened, or OracleConnection has been reopened.
ArgumentOutOfRangeException - Either the src_offset, dst_offset, or amount parameter is less than 0.
The character set of the two OracleClob objects being compared should be the same for a meaningful comparison.
The provided object and the current instance must be using the same connection, that is, the same OracleConnection object.
CopyTo copies data from the current instance to the provided OracleClob object.
This instance method copies data from the current instance to the provided OracleClob object.
This instance method copies data from the current OracleClob instance to the provided OracleClob object with the specified destination offset.
CopyTo(Int64, OracleClob, Int64, Int64)
This instance method copies data from the current OracleClob instance to the provided OracleClob object with the specified source offset, destination offset, and character amounts.
This instance method copies data from the current instance to the provided OracleClob object.
// C#
public Int64 CopyTo(OracleClob obj);
obj
The OracleClob object to which the data is copied.
The return value is the amount copied.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - This exception is thrown if any of the following conditions exist:
The OracleConnection is not open or has been closed during the lifetime of the object.
The LOB object parameter has a different connection than the object.
The provided object and the current instance must be using the same connection, that is, the same OracleConnection object.
This instance method copies data from the current OracleClob instance to the provided OracleClob object with the specified destination offset.
// C# public Int64 CopyTo(OracleClob obj, Int64 dst_offset);
obj
The OracleClob object to which the data is copied.
dst_offset
The offset (in characters) at which the OracleClob object is copied.
The return value is the amount copied.
ObjectDisposedException - The object is already disposed.
ArgumentOutOfRangeException - The dst_offset is less than 0.
InvalidOperationException - This exception is thrown if any of the following conditions exist:
The OracleConnection is not open or has been closed during the lifetime of the object.
The LOB object parameter has a different connection than the object.
If the dst_offset is beyond the end of the OracleClob data, spaces are written into the OracleClob until the dst_offset is met.
The offsets are 0-based. No character conversion is performed by this operation.
The provided object and the current instance must be using the same connection; that is, the same OracleConnection object.
This instance method copies data from the current OracleClob instance to the provided OracleClob object with the specified source offset, destination offset, and character amounts.
// C# public Int64 CopyTo(Int64 src_offset,OracleClob obj,Int64 dst_offset, Int64 amount);
src_offset
The offset (in characters) in the current instance, from which the data is read.
obj
The OracleClob object to which the data is copied.
dst_offset
The offset (in characters) at which the OracleClob object is copied.
amount
The amount of data to be copied.
The return value is the amount copied.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The parameter has a different connection than the object, OracleConnection is not opened, or OracleConnection has been reopened.
ArgumentOutOfRangeException - The src_offset, the dst_offset, or the amount parameter is less than 0.
If the dst_offset is beyond the end of the OracleClob data, spaces are written into the OracleClob until the dst_offset is met.
The offsets are 0-based. No character conversion is performed by this operation.
The provided object and the current instance must be using the same connection, that is, the same OracleConnection object.
// C#
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
class CopyToSample
{
static void Main()
{
string constr = "User Id=scott;Password=tiger;Data Source=oracle";
OracleConnection con = new OracleConnection(constr);
con.Open();
OracleClob clob1 = new OracleClob(con);
OracleClob clob2 = new OracleClob(con);
// Write 4 chars, starting at buffer offset 0
char[] buffer = new char[4] {'a', 'b', 'c', 'd'};
clob1.Write(buffer, 0, 4);
// Copy 2 chars from char 0 of clob1 to char 1 of clob2
clob1.CopyTo(0, clob2, 1, 2);
//Prints "clob2.Value = ab"
Console.WriteLine("clob2.Value = " + clob2.Value);
clob1.Close();
clob1.Dispose();
clob2.Close();
clob2.Dispose();
con.Close();
con.Dispose();
}
}
This instance method releases resources allocated by this object.
public void Dispose();
IDisposable
The object cannot be reused after being disposed. Although some properties can still be accessed, their values cannot be accountable. Since resources are freed, method calls can lead to exceptions.
This instance method closes the CLOB referenced by the current OracleClob instance.
// C# public void EndChunkWrite();
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
Index updates occur immediately if write operation(s) are deferred by the BeginChunkWrite method.
Erase erases part or all data.
This instance method erases all data.
This instance method replaces the specified amount of data (in characters) starting from the specified offset with zero-byte fillers (in characters).
This instance method erases all data.
// C# public Int64 Erase();
The number of characters erased.
This instance method replaces the specified amount of data (in characters) starting from the specified offset with zero-byte fillers (in characters).
// C# public Int64 Erase(Int64 offset, Int64 amount);
offset
The offset.
amount
The amount of data.
The actual number of characters erased.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
ArgumentOutOfRangeException - The offset or amount parameter is less than 0.
Overrides Object
This method returns a hash code for the current instance.
// C# public override int GetHashCode();
An int representing a hash code.
This instance method compares the LOB data referenced by two OracleClobs.
// C#
public bool IsEqual(OracleClob obj);
obj
An OracleClob object.
Returns true if the current OracleClob and the provided OracleClob refer to the same LOB. Otherwise, returns false.
Note that this method can return true even if the two OracleClob objects returns false for == or Equals() because two different OracleClob instances can refer to the same LOB.
The provided object and the current instance must be using the same connection, that is, the same OracleConnection object.
Read reads a specified amount from the current instance and populates the array buffer.
This instance method reads a specified amount of bytes from the current instance and populates the byte array buffer.
This instance method reads a specified amount of characters from the current instance and populates the character array buffer.
Overrides Stream
This instance method reads a specified amount of bytes from the current instance and populates the byte array buffer.
// C# public override int Read(byte [ ] buffer, int offset, int count);
buffer
The byte array buffer that is populated.
offset
The offset (in bytes) at which the buffer is populated.
count
The amount of bytes to be read.
The number of bytes read from the CLOB.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
Both offset and count must be even numbers for CLOB and NCLOB because every two bytes represent a Unicode character.
The LOB data is read starting from the position specified by the Position property, which must also be an even number.
OracleClob is free to return fewer bytes than requested, even if the end of the stream has not been reached.
This instance method reads a specified amount of characters from the current instance and populates the character array buffer.
// C# public int Read(char[ ] buffer, int offset, int count);
buffer
The character array buffer that is populated.
offset
The offset (in characters) at which the buffer is populated.
count
The amount of characters to be read.
The return value indicates the number of characters read from the CLOB.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
ArgumentOutOfRangeException - This exception is thrown if any of the following conditions exist:
The offset or the count is less than 0.
The offset is greater than or equal to the buffer.Length.
The offset and the count together are greater than buffer.Length.
Handles all CLOB and NCLOB data as Unicode.
The LOB data is read starting from the position specified by the Position property.
// C#
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
class ReadSample
{
static void Main()
{
string constr = "User Id=scott;Password=tiger;Data Source=oracle";
OracleConnection con = new OracleConnection(constr);
con.Open();
OracleClob clob = new OracleClob(con);
// Write 3 chars, starting at buffer offset 1
char[] writeBuffer = new char[4] {'a', 'b', 'c', 'd'};
clob.Write(writeBuffer, 1, 3);
// Reset the Position (in bytes) for Read
clob.Position = 2;
// Read 2 chars into buffer starting at buffer offset 1
char[] readBuffer = new char[4];
int charsRead = clob.Read(readBuffer, 1, 2);
// Prints "charsRead = 2"
Console.WriteLine("charsRead = " + charsRead);
// Prints "readBuffer = cd "
Console.Write("readBuffer = ");
for(int index = 0; index < readBuffer.Length; index++)
{
Console.Write(readBuffer[index]);
}
Console.WriteLine();
clob.Close();
clob.Dispose();
con.Close();
con.Dispose();
}
}
Search searches for a character pattern in the current instance of OracleClob.
This instance method searches for a character pattern, represented by the byte array, in the current instance of OracleClob.
This instance method searches for a character pattern in the current instance of OracleClob.
This instance method searches for a character pattern, represented by the byte array, in the current instance of OracleClob.
// C# public int Search(byte[ ] val, Int64 offset, Int64 nth);
val
A Unicode byte array.
offset
The 0-based offset (in characters) starting from which the OracleClob is searched.
nth
The specific occurrence (1-based) of the match for which the absolute offset (in characters) is returned.
Returns the absolute offset of the start of the matched pattern (in bytes) for the nth occurrence of the match. Otherwise, 0 is returned.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
ArgumentOutOfRangeException - This exception is thrown if any of the following conditions exist:
The offset is less than 0.
The nth is less than or equal to 0.
The nth is greater than or equal to OracleClob.MaxSize.
The offset is greater than or equal to OracleClob.MaxSize.
The byte[ ] is converted to Unicode before the search is made.
The limit of the search pattern is 16383 bytes.
This instance method searches for a character pattern in the current instance of OracleClob.
// C# public Int64 Search(char [ ] val, Int64 offset, Int64 nth);
val
The Unicode string being searched for.
offset
The 0-based offset (in characters) starting from which the OracleClob is searched.
nth
The specific occurrence (1-based) of the match for which the absolute offset (in characters) is returned.
Returns the absolute offset of the start of the matched pattern (in characters) for the nth occurrence of the match. Otherwise, 0 is returned.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
ArgumentOutOfRangeException - This exception is thrown if any of the following conditions exist:
The offset is less than 0.
The nth is less than or equal to 0.
The val.Length doubled is greater than 16383.
The nth is greater than or equal to OracleClob.MaxSize.
The offset is greater than or equal to OracleClob.MaxSize.
The limit of the search pattern is 16383 bytes.
// C#
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
class SearchSample
{
static void Main()
{
string constr = "User Id=scott;Password=tiger;Data Source=oracle";
OracleConnection con = new OracleConnection(constr);
con.Open();
OracleClob clob = new OracleClob(con);
// Write 7 chars, starting at buffer offset 0
char[] buffer = new char[7] {'a', 'b', 'c', 'd', 'a', 'b', 'c'};
clob.Write(buffer, 0, 7);
// Search for the 2nd occurrence of a char pattern 'bc'
// starting at offset 1 in the OracleBlob
char[] pattern = new char[2] {'b', 'c'};
long posFound = clob.Search(pattern, 1, 2);
// Prints "posFound = 6"
Console.WriteLine("posFound = " + posFound);
clob.Close();
clob.Dispose();
con.Close();
con.Dispose();
}
}
Overrides Stream
This instance method sets the position on the current LOB stream.
// C# public override Int64 Seek(Int64 offset, SeekOrigin origin);
offset
A byte offset relative to origin.
origin
A value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position.
Returns an Int64 that indicates the position.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
If offset is negative, the new position precedes the position specified by origin by the number of characters specified by offset.
If offset is zero, the new position is the position specified by origin.
If offset is positive, the new position follows the position specified by origin by the number of characters specified by offset.
SeekOrigin.Begin specifies the beginning of a stream.
SeekOrigin.Current specifies the current position within a stream.
SeekOrigin.End specifies the end of a stream.
Overrides Stream
This instance method trims or truncates the CLOB value to the specified length (in characters).
// C#
public override void SetLength(Int64 newlen);
newlen
The desired length of the current stream in characters.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
ArgumentOutOfRangeException - The newlen parameter is greater than 0.
This instance method writes data from the provided array buffer into the OracleClob.
This instance method writes data from the provided byte array buffer into the OracleClob.
This instance method writes data from the provided character array buffer into the OracleClob.
Overrides Stream
This instance method writes data from the provided byte array buffer into the OracleClob.
// C# public override void Write(byte[ ] buffer, int offset, int count);
buffer
The byte array buffer that represents a Unicode string.
offset
The offset (in bytes) from which the buffer is read.
count
The amount of data (in bytes) from the buffer to be written into the OracleClob.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
ArgumentOutOfRangeException - This exception is thrown if any of the following conditions exist:
The offset or the count is less than 0.
The offset is greater than or equal to the buffer.Length.
The offset and the count together are greater than the buffer.Length.
The offset, the count, or the Position is not even.
Both offset and count must be even numbers for CLOB and NCLOB because every two bytes represent a Unicode character.
The LOB data is read starting from the position specified by the Position property. The Position property must be an even number.
If necessary, proper data conversion is carried out from the client character set to the database character set.
This instance method writes data from the provided character array buffer into the OracleClob.
// C# public void Write(char[ ] buffer, int offset, int count);
buffer
The character array buffer that is written to the OracleClob.
offset
The offset (in characters) from which the buffer is read.
count
The amount (in characters) from the buffer that is to be written into the OracleClob.
ObjectDisposedException - The object is already disposed.
InvalidOperationException - The OracleConnection is not open or has been closed during the lifetime of the object.
ArgumentOutOfRangeException - This exception is thrown if any of the following conditions exist:
The offset or the count is less than 0.
The offset is greater than or equal to the buffer.Length.
The offset and the count together are greater than buffer.Length.
The Position is not even.
Handles all CLOB and NCLOB data as Unicode.
The LOB data is read starting from the position specified by the Position property.
If necessary, proper data conversion is carried out from the client character set to the database character set.
// C#
using System;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
class WriteSample
{
static void Main()
{
string constr = "User Id=scott;Password=tiger;Data Source=oracle";
OracleConnection con = new OracleConnection(constr);
con.Open();
OracleClob clob = new OracleClob(con);
// Set the Position for the Write;
clob.Position = 0;
// Begin ChunkWrite to improve performance
// Index updates occur only once after EndChunkWrite
clob.BeginChunkWrite();
// Write to the OracleClob in 5 chunks of 2 chars each
char[] c = new char[2] {'a', 'b'};
for (int index = 0; index < 5; index++)
{
clob.Write(c, 0, c.Length);
}
clob.EndChunkWrite();
// Prints "clob.Value = ababababab"
Console.WriteLine("clob.Value = " + clob.Value);
clob.Close();
clob.Dispose();
con.Close();
con.Dispose();
}
}