The WRITE procedure writes a specified amount of data to an internal LOB (starting from an absolute offset that begins with LOB).
The data is written from the buffer parameter. WRITE replaces (overwrites) any existing data at the specified LOB offset with the specified length.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.
Syntax
DBMS_LOB.WRITE (
lob_loc IN OUT NOCOPY BLOB,
amount IN INTEGER,
offset IN INTEGER,
buffer IN RAW);
DBMS_LOB.WRITE (
lob_loc IN OUT NOCOPY CLOB CHARACTER SET ANY_CS,
amount IN INTEGER,
offset IN INTEGER,
buffer IN VARCHAR2 CHARACTER SET ANY_CS);
Parameters
| Parameter | Description |
|---|---|
| lob_loc | The locator of the internal LOB to write to. For more information, see DBMS_LOB Usage Notes. |
| amount | The number of bytes to write (for BLOB) or characters to write (for CLOB). |
| offset | The offset (starting at 1) in bytes (for BLOB) or characters (for CLOB) at which to start reading the LOB. |
| buffer | The input buffer used for writing. |
Exceptions
| Exception | Description |
|---|---|
| VALUE_ERROR | The lob_loc, mount, or offset parameter is NULL, out of range, or invalid. |
| INVALID_ARGVAL | The value of the parameter is invalid. Possible reasons:
|
| QUERY_WRITE | The LOB write cannot be performed in a query or in a parallel execution server of PDML. |
| BUFFERING_ENABLED | If buffering is enabled for the LOB, the operation cannot be performed when buffering is enabled for the LOB. |
| SECUREFILE_OUTOFBOUNDS | The write operation is attempted and skips the end of the LOB marked with FRAGMENT_ *. |
Considerations
An error occurs if the input size exceeds the buffer data. If the input size is less than the buffer data, only the number of bytes or characters in the buffer is written to the
LOB. If the specified offset exceeds the end of the current data in theLOB, zero-byte fillers or spaces are inserted into theBLOBorCLOB.The
VARCHAR2buffer must match the format of theCLOBparameter. In other words, if the inputLOBparameter is of typeCLOB, the buffer must containCHARdata.When you call
DBMS_LOB.WRITEfrom a client, the buffer must contain data in the client character set. Before writing the buffer data to theLOB, the database converts the client buffer to the server's character set.Wrapping
LOBoperations in the Open/Close interface is not mandatory. If theLOBis not opened before the operation, the functional index and domain index on theLOBcolumn are updated during the call. If theLOBis opened before the operation, it must be closed before the transaction is committed. When the internalLOBis closed, the functional index and domain index on theLOBcolumn are updated.If the
LOBoperation is not wrapped in the Open/Close interface, the functional index and domain index are updated each time theLOBis written. To avoid performance issues, we recommend that you includeLOBwrite operations inOPENorCLOSEstatements.Unless the write operation is specified to overwrite the entire
LOB,WRITEobtains theLOBbefore writing to it.
