The COPY stored procedure is used to copy all or part of a source internal LOB to a destination internal LOB.
You can specify the offset of the source LOB and destination LOB, as well as the number of bytes or characters to copy.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.
Syntax
DBMS_LOB.COPY (
dest_lob IN OUT NOCOPY BLOB,
src_lob IN BLOB,
amount IN INTEGER,
dest_offset IN INTEGER := 1,
src_offset IN INTEGER := 1);
DBMS_LOB.COPY (
dest_lob IN OUT NOCOPY CLOB CHARACTER SET ANY_CS,
src_lob IN CLOB CHARACTER SET ANY_CS,
amount IN INTEGER,
dest_offset IN INTEGER := 1,
src_offset IN INTEGER := 1);
Parameters
| Parameter | Description |
|---|---|
| dest_lob | The LOB locator of the destination. |
| src_lob | The LOB locator of the source. |
| amount | The number of bytes to copy (BLOB) or characters to copy (CLOB). |
| dest_offset | The offset (in bytes or characters, with the origin at 1) of the starting address of the copy in the destination LOB. |
| src_offset | The offset (in bytes or characters, with the origin at 1) of the starting address of the copy in the source LOB. |
Exceptions
| Exception | Description |
|---|---|
| VALUE_ERROR | Any input parameter is NULL or invalid. |
| INVALID_ARGVAL | One of the following conditions is met:
|
| QUERY_WRITE | The LOB write operation cannot be performed in a query. |
| BUFFERING_ENABLED | If buffering is enabled for the LOB, the operation cannot be performed while buffering is enabled for the LOB. |
Considerations
If the specified offset in the destination
LOBexceeds the current end of the data in theLOB, zero-byte fillers or spaces are inserted into the destinationBLOBorCLOB. If the offset is less than the current length of the destinationLOB, the existing data will be overwritten.Specifying a quantity that exceeds the length of the data in the source
LOBdoes not result in an error. Therefore, you can specify a large amount of data to copy from the sourceLOB, which will copy all data from thesrc_offsetto the end of the sourceLOB.It is not mandatory to wrap
LOBoperations within the Open/Close interface. If theLOBis not opened before the operation, the functional index and domain index on theLOBcolumn will be updated during the call. However, if theLOBis opened before the operation, it must be closed before the transaction is committed. When an internalLOBis closed, the functional index and domain index on theLOBcolumn will be updated.If the
LOBoperation is not wrapped within the Open/Close interface, the functional index and domain index will be updated each time theLOBis written. To avoid performance impact, it is recommended to includeLOBwrite operations withinOPENorCLOSEstatements.Before copying, if both the source and destination
LOBare archived, they will be retrieved first. For a full overwrite, the destinationLOBwill not be retrieved.
