Reading the content of a CLOB column

hi all, I uploaded a file to a CLOB column , i would need:

1. to know how I can know if the file has been actually inserted into the column: where / what I have to go / do in order to see if there is some content?

2. I need procedure code to read the content of the CLOB column

Please send just code that actually works and please indicate steps by steps what I have to do to launch the procedure as, even tought I use it, I am not an Oracle procedure and programmig expert  ...

Thank you and regards
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

This is an excellant link for dealing with Oracle clob:
I assume you mean a text (ascii) file; if you meant a binary file, you need a BLOB column, not a CLOB.

Procedure to check if the clob you just inserted is really there:

  vPk number := 123;
  vLen number := 0;
  select dbms_lob.getlength(your_clob)
  into vLen
  from your_table
  where = vPk;
  dbms_output.put_line('vLen: ' || vLen);

if vLen>0, you know there's stuff in the clob.

Now to read it back out, use vLen in a FOR loop to get small chunks (32,000 chars) of the clob at a time, processing each chunk before you grab the next one.
  v_lob_col CLOB;
  v_amt NUMBER(100);
  v_offset NUMBER:=1;
  select lob_col into v_lob_col from your_table where condition...
  if v_lob_col is not null and dbms_lob.length(v_lob_col) >0 then
  loop, v_amt, v_offset, v_buff)
    exit when v_amt = 0;
    dbms_output.put_line(v_buff); -- or something else processing ....
    v_offset := v_offset + v_amt;
  end loop;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

jytrAuthor Commented:
hi konektor, please try your procedure as I get an the line of the if tells me 'ORA-06550: line 7, column 3:
PL/SQL: ORA-00933: SQL command not properly ended'

thanks and regards
because you need to put in your own where clause, and not just cut and paste the procedure.

 select lob_col into v_lob_col from your_table where condition...

is not a valid SQL statement, because there is no condition for the where clause. you need something like

primary_key_col = your_primary_key instead of "condition..."
create procedure read_clob
  clobColumn  clob;
  iClobSize  integer;
  rBuffer  raw(32767);
  vBuffer  varchar2(32767);
  nOffset  number := 1;
  iMaxSize  integer := 32767;
  iChunkSize  integer;
  iLeftOver  integer;
  dbms_lob.createTemporary(clobColumn, true);
  --select lob_col into clobColumn from your_table where....
  iClobSize := dbms_lob.getlength(clobColumn);
  if iClobSize > 0
      iLeftOver := (iClobSize - nOffset + 1);
      if iLeftOver <= iMaxSize
        iChunkSize := iLeftOver;
        iChunkSize := iMaxSize;
      end if;, iChunkSize, nOffset, rBuffer);
      vBuffer := utl_raw.cast_to_varchar2(rBuffer);
      nOffset := nOffset + iMaxSize;
      if nOffset > iClobSize
      end if;
    end loop;
  end if;
end read_clob;
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.