DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: Help with PL/SQL - CLOB

Threaded View

  1. #3
    Join Date
    Nov 2007
    Location
    China
    Posts
    22
    The operation of clob is different from other data types.
    If you want to insert or update a clob column, you must do as below:
    (1) you must go to the clob row firstly;
    (2) then you can update clob column used by dbms_lob package(such as dbms_lob.write, dbms_lob.write, dbms_lob.writeappend);

    Here is an easy example:
    --------------------------------------------------------
    Code:
    create table t_clob2
    (
      no      number,
      content clob
    );
    
    create or replace procedure sp_clob(ip_no number,ip_content varchar2)
    is
      lv_no      number;
      lv_clob    clob;
      lv_sqlstr  varchar2(4000);
    begin
      insert into t_clob2 values(ip_no,empty_clob());
      commit;
      lv_sqlstr := 'select content from t_clob2 where no=' || ip_no || ' for update';
      execute immediate lv_sqlstr into lv_clob;
      dbms_lob.write(lv_clob,length(ip_content),1,ip_content);
      commit;
    end;
    
    SQL> exec sp_clob(1,'abcdefg');
     
    PL/SQL procedure successfully completed
     
    SQL> select * from t_clob2;
     
            NO CONTENT
    --------------------------------------------------------------------------
             1 abcdefg
    /
    Last edited by anyoneokay; 11-29-2007 at 09:05 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width