The READ stored procedure reads data from the specified offset of a LOB and returns it to the buffer parameter.
The amount parameter returns the actual number of bytes (for BLOB) or characters (for CLOB) read. If the input offset exceeds the end of the LOB, amount is set to 0, and the NO_DATA_FOUND exception is raised.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.
Syntax
DBMS_LOB.READ (
lob_loc IN BLOB,
amount IN OUT NOCOPY INTEGER,
offset IN INTEGER,
buffer OUT RAW);
DBMS_LOB.READ (
lob_loc IN CLOB CHARACTER SET ANY_CS,
amount IN OUT NOCOPY INTEGER,
offset IN INTEGER,
buffer OUT VARCHAR2 CHARACTER SET ANY_CS);
Parameters
| Parameter | Description |
|---|---|
| lob_loc | The locator of the LOB to be read. For more information, see DBMS_LOB. |
| file_loc | The file locator of the LOB to be checked. |
| amount | The number of bytes (for BLOB) or characters (for CLOB) to be read, or the number of bytes or characters actually read. |
| offset | The offset at which to start reading the LOB. |
| buffer | The output buffer for the read operation. |
Exceptions
| Exception | Description |
|---|---|
| VALUE_ERROR | The lob_loc, mount, or offset parameter is NULL. |
| INVALID_ARGVAL | The value of the amount parameter is less than 1, greater than 32767 bytes (or equivalent characters), or the value of the offset parameter is less than 1 or greater than LOBMAXSIZE. In addition, the value of the amount parameter in bytes or characters exceeds the buffer capacity. |
| NO_DATA_FOUND | The end of the LOB is reached, and no more bytes or characters are to be read from the LOB, that is, the value of amount is 0. |
Considerations
The
VARCHAR2buffer must match the format of theCLOBparameter. In other words, if the inputLOBparameter is of typeCLOB, the buffer must containCHARdata.When you call
DBMS_LOB.READfrom a client, the returned buffer contains data in the client's character set. Before returning the buffer value to the user, the database converts theLOBvalue from the server's character set to the client's character set.If needed, you can let
READfetch theLOBbefore reading.
