OracleLob.Erase Method (Int64, Int64)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Erases the specified amount of data from this OracleLob.

Namespace:   System.Data.OracleClient
Assembly:  System.Data.OracleClient (in System.Data.OracleClient.dll)

public long Erase(
	long offset,
	long amount


Type: System.Int64

The offset from which to erase. For CLOB and NCLOB data types, this must be an even number.

Type: System.Int64

The quantity of data, in bytes, to erase. For CLOB and NCLOB data types, this must be an even number.

Return Value

Type: System.Int64

The number of bytes erased.

Exception Condition

The operation is not within a transaction, the OracleLob object is null, or the connection is closed.


The object was closed or disposed.


An Oracle error has occurred.

The sum of the values in the offset and amount parameters can be greater than that of the size of the OracleLob. Therefore, specifying a value greater than that returned by the Length property succeeds; however Erase only erases to the end of the OracleLob. (Similarly, if a negative value is passed to offset, Erase will succeed, but only erase starting from the beginning of the OracleLob.) This behavior is different from that of the Read and Write methods, and offers the advantage of being able to erase all data from the value specified by offset without making an additional roundtrip to the server to verify the actual size.

Erase does not truncate data. The LOB length remains the same for a BLOB data type, and the erased data is replaced by 0x00. CLOB and NCLOB data types are replaced by spaces.

To write to the LOB, you must have retrieved the LOB using the FOR UPDATE clause in the SQL SELECT statement, and you must have a local transaction started.


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

.NET Framework
Available since 1.1
Return to top