Updated on 2023-10-31 GMT+08:00

DBMS_LOB

Related Interfaces

Table 1 provides all interfaces supported by the DBMS_LOB package.

Table 1 DBMS_LOB

API

Description

DBMS_LOB.GETLENGTH

Obtains and returns the specified length of a LOB object.

DBMS_LOB.OPEN

Opens a LOB and returns a LOB descriptor.

DBMS_LOB.READ

Loads a part of LOB contents to BUFFER area according to the specified length and initial position offset.

DBMS_LOB.WRITE

Copies contents in BUFFER area to LOB according to the specified length and initial position offset.

DBMS_LOB.WRITEAPPEND

Copies contents in BUFFER area to the end part of LOB according to the specified length.

DBMS_LOB.COPY

Copies contents in BLOB to another BLOB according to the specified length and initial position offset.

DBMS_LOB.ERASE

Deletes contents in BLOB according to the specified length and initial position offset.

DBMS_LOB.CLOSE

Closes a LOB descriptor.

DBMS_LOB.INSTR

Returns the position of the Nth occurrence of a character string in LOB.

DBMS_LOB.COMPARE

Compares two LOBs or a certain part of two LOBs.

DBMS_LOB.SUBSTR

Reads the substring of a LOB and returns the number of read bytes or the number of characters.

DBMS_LOB.TRIM

Truncates the LOB of a specified length. After the execution is complete, the length of the LOB is set to the length specified by the newlen parameter.

DBMS_LOB.CREATETEMPORARY

Creates a temporary BLOB or CLOB.

DBMS_LOB.APPEND

Adds the content of a LOB to another LOB.

  • DBMS_LOB.GETLENGTH

    Specifies the length of a LOB type object obtained and returned by the stored procedure GETLENGTH.

    The function prototype of DBMS_LOB.GETLENGTH is:

    Table 2 DBMS_LOB.GETLENGTH interface parameters

    Parameter

    Description

    lob_loc

    LOB type object whose length is to be obtained

  • DBMS_LOB.OPEN

    A stored procedure opens a LOB and returns a LOB descriptor. This process is used only for compatibility.

    The function prototype of DBMS_LOB.OPEN is:

    Table 3 DBMS_LOB.OPEN interface parameters

    Parameter

    Description

    lob_loc

    BLOB or CLOB descriptor that is opened

    open_mode IN BINARY_INTEGER

    Open mode (currently, DBMS_LOB.LOB_READWRITE is supported)

  • DBMS_LOB.READ

    The stored procedure READ loads a part of LOB contents to BUFFER according to the specified length and initial position offset.

    The function prototype of DBMS_LOB.READ is:

    Table 4 DBMS_LOB.READ interface parameters

    Parameter

    Description

    lob_loc

    LOB type object to be loaded

    amount

    Load data length

    NOTE:

    If the read length is negative, the error message "ERROR: argument 2 is null, invalid, or out of range." is displayed.

    offset

    Indicates where to start reading the LOB contents, that is, the offset bytes to initial position of LOB contents.

    buffer

    Target buffer to store the loaded LOB contents

  • DBMS_LOB.WRITE

    The stored procedure WRITE copies contents in BUFFER to LOB variables according to the specified length and initial position offset.

    The function prototype of DBMS_LOB.WRITE is:

    Table 5 DBMS_LOB.WRITE interface parameters

    Parameter

    Description

    lob_loc

    LOB type object to be written

    amount

    Write data length

    NOTE:

    If the write data is shorter than 1 or longer than the contents to be written, an error is reported.

    offset

    Indicates where to start writing the LOB contents, that is, the offset bytes to initial position of LOB contents.

    NOTE:

    If the offset is shorter than 1 or longer than the maximum length of LOB type contents, an error is reported.

    buffer

    Content to be written

  • DBMS_LOB.WRITEAPPEND

    The stored procedure WRITEAPPEND copies contents in BUFFER to the end part of LOB according to the specified length.

    The function prototype of DBMS_LOB.WRITEAPPEND is:

    Table 6 DBMS_LOB.WRITEAPPEND interface parameters

    Parameter

    Description

    lob_loc

    LOB type object to be written

    amount

    Write data length

    NOTE:

    If the write data is shorter than 1 or longer than the contents to be written, an error is reported.

    buffer

    Content to be written

  • DBMS_LOB.COPY

    The stored procedure COPY copies contents in BLOB to another BLOB according to the specified length and initial position offset.

    The function prototype of DBMS_LOB.COPY is:

    Table 7 DBMS_LOB.COPY interface parameters

    Parameter

    Description

    dest_lob

    BLOB type object to be pasted

    src_lob

    BLOB type object to be copied

    amount

    Length of the copied data

    NOTE:

    If the copied data is shorter than 1 or longer than the maximum length of BLOB type contents, an error is reported.

    dest_offset

    Indicates where to start pasting the BLOB contents, that is, the offset bytes to initial position of BLOB contents.

    NOTE:

    If the offset is shorter than 1 or longer than the maximum length of BLOB type contents, an error is reported.

    src_offset

    Indicates where to start copying the BLOB contents, that is, the offset bytes to initial position of BLOB contents.

    NOTE:

    If the offset is shorter than 1 or longer than the length of source BLOB, an error is reported.

  • DBMS_LOB.ERASE

    The stored procedure ERASE deletes contents in BLOB according to the specified length and initial position offset.

    The function prototype of DBMS_LOB.ERASE is:

    Table 8 DBMS_LOB.ERASE interface parameters

    Parameter

    Description

    lob_loc

    BLOB type object whose contents are to be deleted

    amount

    Length of contents to be deleted

    NOTE:

    If the deleted data is shorter than 1 or longer than the maximum length of BLOB type contents, an error is reported.

    offset

    Indicates where to start deleting the BLOB contents, that is, the offset bytes to initial position of BLOB contents.

    NOTE:

    If the offset is shorter than 1 or longer than the maximum length of BLOB type contents, an error is reported.

  • DBMS_LOB.CLOSE

    The procedure CLOSE disables the enabled contents of LOB according to the specified length and initial position offset.

    The function prototype of DBMS_LOB.CLOSE is:

    Table 9 DBMS_LOB.CLOSE interface parameters

    Parameter

    Description

    src_loc

    LOB type object to be disabled

  • DBMS_LOB.INSTR

    This function returns the Nth occurrence position in LOB. If invalid values are entered, NULL is returned. The invalid values include offset < 1 or offset > LOBMAXSIZE, nth < 1, and nth > LOBMAXSIZE.

    The function prototype of DBMS_LOB.INSTR is:

    Table 10 DBMS_LOB.INSTR interface parameters

    Parameter

    Description

    lob_loc

    LOB descriptor to be searched for

    pattern

    Matched pattern. It is RAW for BLOB and TEXT for CLOB.

    offset

    For BLOB, the absolute offset is in the unit of byte. For CLOB, the offset is in the unit of character. The matching start position is 1.

    nth

    Number of pattern matching times. The minimum value is 1.

  • DBMS_LOB.COMPARE

    This function compares two LOBs or a certain part of two LOBs.

    • If the two parts are equal, 0 is returned. Otherwise, a non-zero value is returned.
    • If the first CLOB is smaller than the second, -1 is returned. If the first CLOB is larger than the second, 1 is returned.
    • If any of the amount, offset_1, and offset_2 parameters is invalid, NULL is returned. The valid offset range is 1 to LOBMAXSIZE.

    The function prototype of DBMS_LOB.READ is:

    Table 11 DBMS_LOB.COMPARE interface parameters

    Parameter

    Description

    lob_1

    First LOB descriptor to be compared

    lob_2

    Second LOB descriptor to be compared

    amount

    Number of characters or bytes to be compared. The maximum value is DBMS_LOB.LOBMAXSIZE.

    offset_1

    Offset of the first LOB descriptor. The initial position is 1.

    offset_2

    Offset of the second LOB descriptor. The initial position is 1.

  • DBMS_LOB.SUBSTR

    This function reads the substring of a LOB and returns the number of read bytes or the number of characters. If amount > 1, amount < 32767, offset < 1, or offset > LOBMAXSIZE, NULL is returned.

    The function prototype of DBMS_LOB.SUBSTR is:

    Table 12 DBMS_LOB.SUBSTR interface parameters

    Parameter

    Description

    lob_loc

    LOB descriptor of the substring to be read. For BLOB, the return value is the number of read bytes. For CLOB, the return value is the number of characters.

    offset

    Number of bytes or characters to be read.

    buffer

    Number of characters or bytes offset from the start position.

  • DBMS_LOB.TRIM

    This stored procedure truncates the LOB of a specified length. After this stored procedure is executed, the length of the LOB is set to the length specified by the newlen parameter. If an empty LOB is truncated, no execution result is displayed. If the specified length is longer than the length of LOB, an exception occurs.

    The function prototype of DBMS_LOB.TRIM is:

    Table 13 DBMS_LOB.TRIM interface parameters

    Parameter

    Description

    lob_loc

    BLOB type object to be read

    newlen

    After truncation, the new LOB length for BLOB is in the unit of byte and that for CLOB is in the unit of character.

  • DBMS_LOB.CREATETEMPORARY

    This stored procedure creates a temporary BLOB or CLOB and is used only for syntax compatibility.

    The function prototype of DBMS_LOB.CREATETEMPORARY is:

    Table 14 DBMS_LOB.CREATETEMPORARY interface parameters

    Parameter

    Description

    lob_loc

    LOB descriptor

    cache

    This parameter is used only for syntax compatibility.

    dur

    This parameter is used only for syntax compatibility.

  • DBMS_LOB.APPEND

    The stored procedure READ loads a part of BLOB contents to BUFFER according to the specified length and initial position offset.

    The function prototype of DBMS_LOB.APPEND is:

    Table 15 DBMS_LOB.APPEND interface parameters

    Parameter

    Description

    dest_lob

    LOB descriptor to be written

    src_lob

    LOB descriptor to be read

Examples