This documentation is archived and is not being maintained.

OracleLob.SetLength Method

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Sets the length of the OracleLob stream to a value less than the current length.

[Visual Basic]
Overrides Public Sub SetLength( _
   ByVal value As Long _
public override void SetLength(
 long value
public: void SetLength(
 __int64 value
public override function SetLength(
   value : long


The desired length of the current OracleLob stream in bytes. For CLOB and NCLOB data types, this must be an even number.


Exception Type Condition
ArgumentOutOfRangeException A value specified in the value parameter for a CLOB or NCLOB data type is not even.


A value specified in the value parameter is less than zero, or greater than 4 gigabytes.

InvalidOperationException Writing to a LOB requires that the operation be within a transaction.


The OracleLob object is null.


The connection is closed.

ObjectDisposedException The object was closed or disposed.
OracleException An Oracle error has occurred.


An attempt to increase the length of the OracleLob stream fails, and returns "Message: ORA-22926: specified trim length is greater than current LOB value's length" from the Oracle server.

A stream must support both writing and seeking for SetLength to function.

The .NET Framework Data Provider for Oracle handles all CLOB and NCLOB data as Unicode. Therefore, when accessing CLOB and NCLOB data types, you are always dealing with the number of bytes, where each character is 2 bytes. For example, if a string of text containing three characters is saved as an NCLOB on an Oracle server where the character set is 4 bytes per character, and you perform a SetLength operation, you specify the length of the string as 6 bytes although it is stored as 12 bytes on the server.

Note   In this release, a write operation to a read-only LOB might succeed, but will not update the LOB on the server. In this case, however, the local copy of the LOB will be updated. Therefore, subsequent read operations on the OracleLob object might return the results of the write operation.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

OracleLob Class | OracleLob Members | System.Data.OracleClient Namespace