The DBMS_LOB package provides most LOB operations for reading and modifying BLOB and CLOB values.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.
Privilege requirements for DBMS_LOB
The DBMS_LOB package must be created in the SYS schema. However, the operations provided by this package are executed under the privileges of the current user, not in the SYS schema.
Any DBMS_LOB subprogram called from an anonymous PL block is executed under the privileges of the current user. Any DBMS_LOB subprogram called from a stored subprogram is executed under the privileges of the owner of the stored subprogram.
When creating a subprogram, you can set the AUTHID parameter to specify whether the subprogram should use the privileges of the definer or the invoker. Here are two examples:
CREATE PROCEDURE proc1 AUTHID DEFINER ...
or
CREATE PROCEDURE proc1 AUTHID CURRENT_USER ...
Data types used by DBMS_LOB
| Data type | Description |
|---|---|
| BLOB | The source or destination binary LOB. |
| RAW | The source or destination RAW buffer (used with BLOB). |
| CLOB | The source or destination character LOB. |
| VARCHAR2 | The source or destination character buffer (used with CLOB). |
| INTEGER | The size of the buffer or LOB, the offset of the LOB, or the number of elements to access. |
Considerations for using DBMS_LOB
All DBMS_LOB subprograms operate based on LOB locators. To successfully execute DBMS_LOB subprogram operations, you must provide an input locator that represents an existing LOB in the database tablespace or external file system.
All DBMS_LOB APIs now support operations on remote LOB locators. Any API that uses two locators must have both LOB values in the same database.
Overview of DBMS_LOB subprograms
The following table lists the DBMS_LOB subprograms supported in the current version of OceanBase Database and their brief descriptions.
| Subprogram | Description |
|---|---|
| APPEND | Appends the content of the source LOB to the destination LOB. |
| CLOSE | Closes a previously opened internal or external LOB. |
| COPY | Copies all or part of the source internal LOB to the destination internal LOB. |
| CREATETEMPORARY | Creates a temporary BLOB or CLOB and the corresponding index in the default temporary tablespace. |
| ERASE | Erases all or part of the LOB. |
| FREETEMPORARY | Frees the temporary BLOB or CLOB in the default temporary tablespace. |
| GETLENGTH | Retrieves the length of the LOB value. |
| ISOPEN | Checks whether the LOB is opened using the input locator. |
| INSTR | Returns the position of the nth occurrence of a match in LOB mode. |
| ISTEMPORARY | Checks whether the locator points to a temporary LOB. |
| OPEN | Opens the LOB in the specified mode (internal, external, or temporary). |
| READ | Reads data from the LOB starting at the specified offset. |
| SUBSTR | Returns a portion of the LOB value starting at the specified offset. |
| TRIM | Trims the LOB value to the specified shorter length. |
| WRITE | Writes data to the LOB starting at the specified offset. |
| WRITEAPPEND | Writes the buffer to the end of the LOB. |
| CONVERTTOBLOB | Converts the character data of the source CLOB to binary data and writes it to the destination BLOB. |
