Friday 14 December 2007

Adding data to CLOB fileds

Test table to try CLOBS

create table a (
id number primary key,
name varchar2(32),
info clob
);

insert into a values(1, 'Nazrul', 'Notest');
insert into a values(2 'Abu', 'You can add here upto 3999 char via sqlplus');


Good to use LOB function to do CLOB work so you can add upto 4gb of data.

DECLARE
v_text_loc CLOB;
v_offset INTEGER;
v_buffer VARCHAR2(100);
BEGIN
select info into v_text_loc from a where id = 15;
v_offset := DBMS_LOB.GETLENGTH (v_text_loc) + 1;
v_buffer := 'My txt The End.';
DBMS_LOB.WRITE (v_text_loc, length(v_buffer), v_offset, v_buffer);
END;
/

select '*'||info||'*' from a where id = 15;

No comments: