The CONVERTTOBLOB procedure converts character data in a source CLOB to binary data and writes the binary data to a destination BLOB. This procedure encodes the character data into binary format based on the specified character set ID. It is suitable for scenarios such as encryption, compression, or network transmission requiring binary format.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only MySQL mode.
Syntax
DBMS_LOB.CONVERTTOBLOB (
dest_lob IN OUT NOCOPY BLOB,
src_clob IN CLOB CHARACTER SET ANY_CS,
amount IN INTEGER,
dest_offset IN INTEGER DEFAULT 1,
src_offset IN INTEGER DEFAULT 1,
blob_csid IN INTEGER,
lang_context IN OUT INTEGER,
warning OUT INTEGER);
Parameters
| Parameter | Description |
|---|---|
| dest_lob | The locator of the destination BLOB to which the converted binary data will be written. The LOB must be writable. |
| src_clob | The locator of the source CLOB containing the character data to be converted. |
| amount | The number of characters to be converted. You can use DBMS_LOB.LOBMAXSIZE to convert the entire LOB. |
| dest_offset | The starting position (in bytes, with the origin at 1) in the destination BLOB where the data will be written. The default value is 1. |
| src_offset | The starting position (in characters, with the origin at 1) in the source CLOB from which the data will be read. The default value is 1. |
| blob_csid | The character set ID of the destination BLOB, which determines how the character data is encoded into binary format. |
| lang_context | An internal language context parameter for character set conversion. It must be initialized to the default value before the first call. |
| warning | An output parameter used to return warning information (such as data truncation). |
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. |
| NOT_SUPPORTED | The CONVERTTOBLOB operation is not supported for temporary Delta-type LOBs; or the destination LOB is read-only and cannot be modified. |
Considerations
If the specified offset in the destination
BLOBexceeds the current data length, zero-byte padding is inserted. If the offset is less than the current length of the destinationBLOB, the existing data will be overwritten.Specifying
amountasDBMS_LOB.LOBMAXSIZEindicates converting all data from thesrc_offsetto the end of the sourceCLOB.It is not mandatory to wrap
LOBoperations within an Open/Close interface. If theLOBis not opened before executing the operation, the function and domain indexes on theLOBcolumn will be updated during the call. However, if theLOBis opened before executing the operation, it must be closed before the transaction is committed.
