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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
-- Obtain the length of the character string.
SELECT DBMS_LOB.GETLENGTH('12345678');

DECLARE
myraw  RAW(100);
amount INTEGER :=2;
buffer INTEGER :=1;
begin
DBMS_LOB.READ('123456789012345',amount,buffer,myraw);
dbms_output.put_line(myraw);
end;
/

CREATE TABLE blob_Table (t1 blob) DISTRIBUTE BY REPLICATION;
CREATE TABLE blob_Table_bak (t2 blob) DISTRIBUTE BY REPLICATION;
INSERT INTO blob_Table VALUES('abcdef');
INSERT INTO blob_Table_bak VALUES('22222');

DECLARE
str varchar2(100) := 'abcdef';
source raw(100);
dest blob;
copyto blob;
amount int;
PSV_SQL varchar2(100);
PSV_SQL1 varchar2(100);
a int :=1;
len int;
BEGIN
source := utl_raw.cast_to_raw(str);
amount := utl_raw.length(source);

PSV_SQL :='select * from blob_Table for update';
PSV_SQL1 := 'select * from blob_Table_bak for update';

EXECUTE IMMEDIATE PSV_SQL into dest;
EXECUTE IMMEDIATE PSV_SQL1 into copyto;

DBMS_LOB.WRITE(dest, amount, 1, source);
DBMS_LOB.WRITEAPPEND(dest, amount, source);

DBMS_LOB.ERASE(dest, a, 1);
DBMS_OUTPUT.PUT_LINE(a);
DBMS_LOB.COPY(copyto, dest, amount, 10, 1);
DBMS_LOB.CLOSE(dest);
RETURN;
END;
/

--Delete the table.
DROP TABLE blob_Table;
DROP TABLE blob_Table_bak;