The DBMS_LOB package provides most LOB operations, such as reading and modifying BLOB and CLOB values.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only MySQL-compatible mode.
Privilege requirements for DBMS_LOB
The DBMS_LOB package must be created under the SYS user. However, the operations provided by this package are executed under the current calling user, not under the SYS user.
Any DBMS_LOB subprogram called from an anonymous PL block is executed using the privileges of the current user. Any DBMS_LOB subprogram called from a stored subprogram is executed using the privileges of the stored subprogram owner.
When creating a subprogram, you can set the AUTHID parameter to specify whether the subprogram uses 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 value. |
| RAW | The source or destination RAW buffer, used with BLOB. |
| CLOB | The source or destination character LOB value. |
| 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 items to access. |
Considerations for using DBMS_LOB
All DBMS_LOB subprograms operate based on LOB locators. To successfully complete a DBMS_LOB subprogram operation, 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 an internally or externally stored LOB that was previously opened. |
| 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 | Releases the temporary BLOB or CLOB in the default temporary tablespace. |
| GETLENGTH | Retrieves the length of the LOB value. |
| ISOPEN | Checks whether the LOB is already 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. |