Technology Software

How to Insert CLOB in Oracle

    • 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

Related posts "Technology : Software"

How to Capture Analog Audio on My Computer

Software

Effective Photoshop Training Course to Enhance Your Photos

Software

How To Use Softphone Software For Your Business

Software

How to Access a String Array in JSP

Software

How Do I Get a Reversible Reaction Arrow in Microsoft Word 2007?

Software

How to Get AVCHD (MTS) Files to My PC

Software

Beat Detective Region Conform Tips

Software

MS BKF Repair Tool to Fix Corruption Owing to FAT File System

Software

Making an ASM Comparison

Software

Leave a Comment