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
| create or replace procedure updateblob(
ctbl in varchar2,
cfld in varchar2,
cstr in varchar2,
ccond in varchar2
)
is
vqry varchar2(1000);
vblob blob;
vbatch varchar2(2000);
vstrlen number;
voffset number :=1;
vamt number :=2000;
begin
vstrlen := length(cstr);
vqry := 'update '||ctbl||' set '||cfld||'=empty_blob() where '||ccond;
execute immediate vqry;
vqry := 'select '||cfld||' from '||ctbl||' where '||ccond||' for update';
execute immediate vqry into vblob;
if vstrlen>vamt then
while vstrlen>voffset loop
vbatch := substr(cstr, voffset, vamt);
voffset := voffset+vamt;
dbms_lob.writeappend(vblob, length(vbatch), utl_raw.cast_to_raw(vbatch));
end loop;
else
dbms_lob.writeappend(vblob, length(cstr), utl_raw.cast_to_raw(cstr));
end if;
commit;
end;
|