- 1). Create a temporary table with a CLOB data type as follows at the "SQL>" prompt in SQLPlus:
create table clobtable (id number, clob_data CLOB);
The table can now be used to enter and reference CLOB data via the id field and the clob_data field storing the actual information. - 2). Create code to populate the CLOB field in the database. This is achieved by writing up an anonymous block as follows:
DECLARE
vlob_loc CLOB;
charcount binary_integer;
position integer := 1;
v_charclob varchar2(32000);
begin
for i in 1..12000 loop
v_charclob := v_charclob || 'x';
end loop;
insert into clobtable values (12, empty_clob());
charcount := LENGTH(v_charclob);
select clob_data into vlob_loc from clobtable where id=12;
DBMS_LOB.WRITE(vlob_loc, charcount, position, v_charclob);
dbms_output.put_line('CLOB Row Inserted');
END; - 3). Test the CLOB insert. This can be achieved by selecting the contents of the table thus:
Select * from clobtable;
The output should be:
ID CLOB_DATA
12 xxxxxxxxxxxxxxxx ... etc
previous post