COPY

2024-03-05 01:54:27  Updated

The COPY stored procedure copies all or part of a source internal LOB to a target internal LOB.

You can specify the offset for the source LOB and target LOB and the number of bytes or characters to be copied.

Applicability

This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.

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 locator of the target LOB.
src_lob The locator of the source LOB.
amount The amount of data to be copied. The value is in bytes for BLOBs and in characters for CLOBs.
dest_offset The offset, with 1 as the origin, for the start of copy in the target LOB. The value is in bytes or characters.
src_offset The offset, with 1 as the origin, for the start of copy in the source LOB. The value is in bytes or characters.

Exceptions

Exception Description
VALUE_ERROR Any input parameters are NULL or invalid.
INVALID_ARGVAL Several possibilities:
  • The value of src_offset or dest_offset is smaller than 1.
  • The value of the src_offset or dest_offset parameter is greater than the value of LOBMAXSIZE.
  • The value of the amount parameter is less than 1.
  • The value of the amount parameter is greater than the value of LOBMAXSIZE.
QUERY_WRITE LOB write is not allowed in the query.
BUFFERING_ENABLED The operation cannot be performed because LOB buffering is enabled.

Considerations

  • If the offset specified in the target LOB is beyond the end of the data in the LOB, the target BLOB will be filled with zero bytes, and the target CLOB will be filled with spaces. If the offset is less than the current length of the target LOB, the existing data will be overwritten.

  • No error will occur if the specified amount exceeds the data length of the source LOB. Therefore, you can specify a large amount of data to be copied from the source LOB. This way, data starting from the offset position determined by src_offset to the end of the source LOB is copied.

  • You can choose not to wrap the LOB operation inside the Open/Close API. If you did not open the LOB before the operation, the functional and domain indexes on the LOB column are updated during the call. However, if you opened the LOB before the operation, you must close it before you commit the transaction. When an internal LOB is closed, the functional and domain indexes on the LOB column are updated.

    If you do not wrap the LOB operation in the Open/Close API, the functional and domain indexes are updated each time you write to the LOB. To avoid adversely affecting performance, we recommend that you wrap write operations on the LOB in the OPEN or CLOSE statement.

  • If the source and target LOBs are archived, the procedure retrieves them before copying data. In case of a complete overwrite, the procedure does not retrieve the target LOB.

Contact Us