Update of CLOB column issue

I am not sure if this is the correct forum for this question, so please forgive if this is posted in wrong forum.
I am new to working with CLOBs in Oracle. The procedure updates a CLOB column which stores large XML files. The XML files are first moved to the /u04 directory, then we execute the procedure which looks for the XML in /u04, then uses those XML files to update the CLOB column.
The procure works fine in our development environment, but doesn't work in our System Test box. No exceptions are thrown in Sys Test, but when we check the CLOB column it's NULL/empty.
Both Dev and Sys Test environments are on the same physical server.
Is there something in the database setup I should be looking for which may cause this difference in functionality?
Code is below. I'm sure it could be better but this is my first go-around with CLOBs.
Any help is greatly appreciated!
  --open CLOB used to clear out old XML in CLOB column
   dbms_lob.open(v_pre_clob, dbms_lob.lob_readwrite);
   -- prep XML CLOB column for update
   UPDATE REPORT_TBL
      SET REPORT_XML = v_pre_clob
    WHERE REPORT_ID = p_rep_id;
   --Close pre-update CLOB
   dbms_lob.close(v_pre_clob);
   --get a reference to the XML CLOB that needs to be updated
   select report_xml
     into v_clob
     from report_tbl
    where report_id = p_rep_id for update;   
   --open the target CLOB and source report xml file in /u04
   dbms_lob.open(v_clob, dbms_lob.lob_readwrite);
   dbms_lob.open(v_report_xml_file);
   --Load the contents of the xml file in /u04 into the CLOB column
   dbms_lob.loadclobfromfile(v_clob, v_xml_file,
                             dbms_lob.lobmaxsize,
                             v_destination_offset, v_source_offset,
                             nls_charset_id('US7ASCII'),
                             v_language_context, v_warning_message);
   --Check for the only possible warning message.
   if v_warning_message = dbms_lob.warn_inconvertible_char then
        dbms_output.put_line('Warning! Some characters couldn''t be converted.');  
   end if;
   --Close both LOBs
   dbms_lob.close(v_clob);
   dbms_lob.close(v_xml_file);
   null;
   EXCEPTION
      WHEN OTHERS THEN
         v_return_code := SQLCODE;
         v_return_mesg := SQLERRM;
         DBMS_OUTPUT.PUT_LINE('PROCEDURE update_xml_from_file');
         DBMS_OUTPUT.PUT_LINE('RETURN_CODE = ' || v_return_code);
         DBMS_OUTPUT.PUT_LINE('RETURN_MESG = ' || v_return_mesg);

Sorry, pulled that code from development where it was working.
The issue was the GRANT on the /u04 directory.

Similar Messages

  • How to Update a clob column..it gives error string literal too long

    I am trying to update a clob column of a table but it gives error string literal too long plz tell me what's the issue
    ORA-01704: string literal too long

    Peeyush wrote:
    I am trying to update a clob column of a table but it gives error string literal too long plz tell me what's the issue
    ORA-01704: string literal too longThere's a problem with my car. It won't start. Why won't it start? Please tell me!
    Oh wait, you can't, because I haven't given you nearly enough information...
    In other words, if you would like help in trying to work out where you've gone wrong, you should provide a small enough example of your code that demonstrates the error. We might then actually stand a chance of being able to help you!

  • Updating a CLOB column using C++ with ATL

    Hello,
    I have tables with a single CLOB or BLOB colum with the rest of the columns of type VARCHAR2.
    I'm getting a result of E_FAIL when updating a single row, for which I'm attempting to change one of the VARCHAR2 columns and the CLOB column. If I set the status for the CLOB column to DBSTATUS_S_IGNORE, the update succeeds (for the other column). If I set the status for all other columns to DBSTATUS_S_IGNORE and the status for the CLOB column to DBSTATUS_S_OK, it still fails.
    If I use a SQL Server data source with the same schema and the same C++ code, the original update succeeds.
    The length of the data I'm attempting to store is 11487 characters.
    As near as I can tell, the Oracle provider does support this kind of functionality. Perhaps there is some coding variation needed for the Oracle data source. I have so far been unable to find a suitable example (or any code example for the Oracle provider using C++/ATL).
    I'm using Oracle 9i Release 2 with the latest OLE DB provider (9.2.0.2.0).
    Thanks,
    Daniel E. Hale
    [email protected]

    Some additional information on the problem:
    I was using the ISequentialStream interface
    with a Dynamic Accessor when the problem
    occurred.
    Since then I've tried using a SQL command to do
    the update... and I've found the 11487 characters
    is too long... I get a maximum length error when
    I try the command in SQL+. (BTW, SQL Server works
    fine with the long command.)
    I doubt that the length is the reason for the failure
    of the update using the ISequentialStream interface.
    I'm just looking for something that works. Right
    now, the only thing that works is not to do the
    update at all, but instead do delete/insert. I'd
    like to find a better solution than that.
    -Daniel E. Hale

  • Data updated by another user when trying to update a CLOB column value

    I just recently upgraded to version 1.2.1 (Build MAIN-32.13), and since I have, I am now getting this message when editing the text within a CLOB column of a table:
    Data you attempted to update was updated by another user. You will have to rollback and refresh the table. Rollback now?
    I am confident that no one else is in the table, as I am the only one connected to this DB right now. Also, I have shut down SQL Developer completely and restarted it. Again, I get the same error.
    Also, the CLOB is less than 2500 characters, so it's not a limitation with the 4k chars.
    I really can't update it easily via SQL because there is formatting in the text (carriage
    returns, etc).
    Any ideas? Any workarounds?
    Thanks,
    -Vikki

    OK. A few things I've noticed as I've played with it more.
    1 - It does not happen on EVERY update to a CLOB. (Some save successfully.)
    2 - Once I get it on a CLOB, it seems to happen then on every subsequent CLOB.
    3 - It's not just one table -- several tables do it.
    4 - It's not even just updating CLOB columns -- I just had it happen on a varchar2 column where there is also a CLOB in the table.
    Thank you for the instructions on how to see the debug console. Here is what I got as an exception (and sorry for the line wrapping):
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.S
    tring
    at oracle.dbtools.raptor.controls.celleditor.ResultSetCellEditor$1.actio
    nPerformed(ResultSetCellEditor.java:140)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:18
    49)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
    a:2169)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
    .java:420)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
    istener.java:234)
    at java.awt.Component.processMouseEvent(Component.java:5488)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
    at java.awt.Component.processEvent(Component.java:5253)
    at java.awt.Container.processEvent(Container.java:1966)
    at java.awt.Component.dispatchEventImpl(Component.java:3955)
    at java.awt.Container.dispatchEventImpl(Container.java:2024)
    at java.awt.Component.dispatchEvent(Component.java:3803)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
    at java.awt.Container.dispatchEventImpl(Container.java:2010)
    at java.awt.Window.dispatchEventImpl(Window.java:1774)
    at java.awt.Component.dispatchEvent(Component.java:3803)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
    read.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.S
    tring
    at oracle.dbtools.raptor.controls.celleditor.ResultSetCellEditor$1.actio
    nPerformed(ResultSetCellEditor.java:140)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:18
    49)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
    a:2169)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
    .java:420)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
    istener.java:234)
    at java.awt.Component.processMouseEvent(Component.java:5488)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
    at java.awt.Component.processEvent(Component.java:5253)
    at java.awt.Container.processEvent(Container.java:1966)
    at java.awt.Component.dispatchEventImpl(Component.java:3955)
    at java.awt.Container.dispatchEventImpl(Container.java:2024)
    at java.awt.Component.dispatchEvent(Component.java:3803)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
    at java.awt.Container.dispatchEventImpl(Container.java:2010)
    at java.awt.Window.dispatchEventImpl(Window.java:1774)
    at java.awt.Component.dispatchEvent(Component.java:3803)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
    read.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
    ad.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    reloadBuffers(): 56 nodes checked in 0.001488707 second(s)
    reloadBuffers(): 56 nodes checked in 0.001101633 second(s)
    reloadBuffers(): 56 nodes checked in 8.70581E-4 second(s)
    reloadBuffers(): 56 nodes checked in 0.00159078 second(s)

  • How to update a CLOB column

    here is my problem.
    I have a table called t_clob as follows:
    SQL> desc t_clob
    Name Null? Type
    C CLOB
    I need to update an existing row with new data (overwrite). The new data is a big java script string with line break, spaces, alignment etc. as follows :
    <form name="abcdeg" accept-charset="utf-8" class="adadad" method="get" action="abd/def" id="asdsdas">
    <label class="abcdef" for="sdfgsdgjgerigh">Search</label>
    <div class="qwert">
    <label class="qwert">
    <input type="radio" name="search_type" value="wweer" id="qwert_trye" onclick="aab(ddgdfgdf);switchTo(''abcd'');" class="radio" <#if localchecked??> ${localchecked}</#if> />Site
    </label>
    <label class="abcdefgh">
    <input type="radio" name="asddfere" value="sssd" id="sdfswererwerew" onclick="abcdefghij(this.value);switchTo(''dfsdfs'');" class="radio" <#if webchecked??> ${sdfsdfsdf}</#if> style="display:none" disabled />
    <input type="radio" name="sdfsdfsdfs" value="fsdfsdfsdf" id="sdfsdfsdfsd" onclick="sdfsdfsdfsdfsdfsdf(this.value);" class="radio" <#if sfsdfsdfsdf??> ${sdfsdfsdfsdf}</#if> /> qwe
    </label>
    <label class="sdfdsfsdfs" style="font-size:8px">
                                  sfsdfsdf <br>
                                  <img src="/sdfsd/sdfsd/sfsdfsd.lfg" alt="Search"/>
                             </label>
                             <label class="qweqwe" style="display:none">
    <input type="radio" name="qwewewqe" value="weqwewq" id="qweqweqwewqeq" onclick="weqweqweqeqweqw(this.value);switchTo(''business'');" class="radio" <#if localbusinesschecked??> ${qweqweweqwe}</#if> />qweqweqw
    </label>
    </div>
    <input type="text" value="<#if q??>${q}</#if>" name="qweqwewqe" id="qweqweqwew" autocomplete="off"/>
    <button type="submit" onclick="qweqweqweqw()">
    <img src="/weqweqw/qweqweqwe.gif" alt="Search" />
    </button>
                        <input type="hidden" value="<#if sm??>${sm}</#if>" id="sm" name="qwe" class="hidden"/>
                        <input type="hidden" value="<#if srm??>${srm}</#if>" id="srm" name="srm" class="hidden"/>
                        <input type="hidden" id="startIndex" name="startIndex" value="<#if start??>${start}</#if>"/>
                        <input type="hidden" id="currentPage" name="currentPage" value="<#if currentpage??>${currentpage}</#if> "/>
    </form>
    <script type="text/javascript">
    window.qweqwewq = "<#if appid??>${appid}</#if>";
    </script>
    <script type="text/javascript" src="http://qwewqeqwewewe/qwewq/qwew/qweqwe.js"></script>
    Currently, we have the normal update statement (updating as a varchr value) in a .sql file. but running the .sql file, throws the following error:
    SP2-0042: unknown command "</script>" - rest of line ignored.
    SP2-0734: unknown command beginning "<script ty..." - rest of line ignored.
    SP2-0734: unknown command beginning "where EXT..." - rest of line ignored.
    For a work-around, we are updating the column through TOAD --> Schema Browser--> Data tab. But, this TOAD way is appearing to be error prone, though it works.
    Can anybody help us in modifying the update statement so that it can directly be run from the .sql file and the spacing/ new lines are preserved.
    Thanks in Advance.

    I'm not 100% sure i understand your problem, is this of any help?
    ME_XE?create table t1 (id number, col1 clob);
    Table created.
    Elapsed: 00:00:00.10
    ME_XE?insert into t1 (id) values (1);
    1 row created.
    Elapsed: 00:00:00.01
    ME_XE?
    ME_XE?declare
      2     my_clob clob default
      3     '
      4     <form name="abcdeg" accept-charset="utf-8" class="adadad" method="get" action="abd/def" id="asdsdas">
      5     <label class="abcdef" for="sdfgsdgjgerigh">Search</label>
      6     <label class="qwert">
      7     <input type="radio" name="search_type" value="wweer" id="qwert_trye" onclick="aab(ddgdfgdf);switchTo(''abcd'');" class="radio" <#if localchecked??> ${localchecked}</#if> />Site
      8     </label>
      9     <label class="abcdefgh">
    10     <input type="radio" name="asddfere" value="sssd" id="sdfswererwerew" onclick="abcdefghij(this.value);switchTo(''dfsdfs'');" class="radio" <#if webchecked??> ${sdfsdfsdf}</#if> style="display:none" disabled />
    11     <input type="radio" name="sdfsdfsdfs" value="fsdfsdfsdf" id="sdfsdfsdfsd" onclick="sdfsdfsdfsdfsdfsdf(this.value);" class="radio" <#if sfsdfsdfsdf??> ${sdfsdfsdfsdf}</#if> /> qwe
    12     </label>
    13     <label class="sdfdsfsdfs" style="font-size:8px">
    14     sfsdfsdf
    15     <img src="/sdfsd/sdfsd/sfsdfsd.lfg" alt="Search"/>
    16     </label>
    17     <label class="qweqwe" style="display:none">
    18     <input type="radio" name="qwewewqe" value="weqwewq" id="qweqweqwewqeq" onclick="weqweqweqeqweqw(this.value);switchTo(''business'');" class="radio" <#if localbusinesschecked??> ${qweqweweqwe}</#if> />qweqweqw
    19     </label>
    20     <input type="text" value="<#if q??>${q}</#if>" name="qweqwewqe" id="qweqweqwew" autocomplete="off"/>
    21     <button type="submit" onclick="qweqweqweqw()">
    22     <img src="/weqweqw/qweqweqwe.gif" alt="Search" />
    23     </button>
    24     <input type="hidden" value="<#if sm??>${sm}</#if>" id="sm" name="qwe" class="hidden"/>
    25     <input type="hidden" value="<#if srm??>${srm}</#if>" id="srm" name="srm" class="hidden"/>
    26     <input type="hidden" id="startIndex" name="startIndex" value="<#if start??>${start}</#if>"/>
    27     <input type="hidden" id="currentPage" name="currentPage" value="<#if currentpage??>${currentpage}</#if> "/>
    28     </form>
    29     <script type="text/javascript">
    30     window.qweqwewq = "<#if appid??>${appid}</#if>";
    31     </script>
    32     <script type="text/javascript" src="http://qwewqeqwewewe/qwewq/qwew/qweqwe.js"></script>
    33     ';
    34
    35  begin
    36     update t1 set col1 = my_clob where id = 1;
    37  end;
    38  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.03
    ME_XE?

  • Updating a CLOB using the JDBC 8.1.6 driver

    I have two issues on which comments are welcome. ( I am using the thin driver )
    1. Using the JDBC 2.0 way of updating a CLOB
    is not possible as the manuals state that
    this can cause "serious corruption".
    2. Using the Oracle specific way ( using
    Oracle specific classes ), it looks like
    I cant update a CLOB column without
    retrieving it first.
    It looks like I need a handle to the CLOB
    in a CLOB object before I can update it.
    This is very frustrating because in my application, we retrieve objects from a database, may keep the object in memory for
    a long time and then update the object from
    the in-memory copy. If I had to use the Oracle specific way of updating clobs, every
    time I need to update a clob, I need to
    retrieve the clob first and then update it
    which runs contrary to handling of other types of columns.
    null

    Ah. I think you're referring to:
    In the implementation of the Oracle JDBC drivers, this functionality is supported only for a configuration using an 8.1.6 database and 8.1.6 JDBC OCI driver. Do not use this functionality for any other configuration, as data corruption can result.
    yeah, that's about what I'm seeing. Anything over 4k blows up. Hopefully the 8.1.6 driver + DBMS will fix these problems.
    Has anyone out there tried it? Can we use the GetClob/GetBlob, or even the getXXXStream() methods in 8.1.6 against CLOB/BLOB columns
    ? I sure hope so. SQL Server and mySQL :-)drivers can both handle it.

  • Limitation for CLOB columns? - ORA-01704: string literal too long

    Hello!
    I'm trying to update a CLOB column with more than 35000 characteres, but I get "ORA-01704: string literal too long".
    The code:
    declare
    l_clob clob;
    begin
    update test set test = empty_clob()
    WHERE ID = 1
    returning test into l_clob;
    dbms_lob.write( l_clob, length('A...here 35000xA...A'), 1,'A...here 35000xA...A');
    end;
    Is there any limitation for CLOB columns?
    Thanks for help.
    Daniel

    user605489 wrote:
    32768 characteres :)Actually it's 1 character less than 32K...
    *32767*
    SQL> declare
      2    v_vc varchar2(32768);
      3  begin
      4    null;
      5  end;
      6  /
      v_vc varchar2(32768);
    ERROR at line 2:
    ORA-06550: line 2, column 17:
    PLS-00215: String length constraints must be in range (1 .. 32767)
    SQL>I guess it comes from a legacy thing where signed words (2 bytes) are/were used to represent a value. As the most significant bit of the word is used to represent the sign of the number the range goes from -32768 to 32767.

  • ODI PDF to CLOB column

    Hi,
    How should I read a PDF content from some file share location and update a CLOB column in target DB.
    My Source is PDF file and target is Oracle DB.
    thanks
    Sanjeeva

    Easy way of getting LOBs is via external table, this external table below will give you all the file names in a file with name 'files_to_load.dat' and a BLOB column for each file.
    Directories used in external table;
    create directory dir_data as 'd:\\temp\\data';
    create directory dir_out_log as 'd:\\temp\\logs';
    create directory dir_out_bad as 'd:\\temp\\logs';
    External table definition;
    CREATE TABLE blob_data_et
    FILE_NM varchar2(120),
    file_data blob
    organization external
    type oracle_loader
    default directory dir_data
    access parameters
    records delimited by NEWLINE
    skip 1
    logfile dir_out_log:'dir_data.log'
    badfile dir_out_bad:'dir_data.bad'
    nodiscardfile
    fields terminated by ','
    missing field values are null
    FILE_NM CHAR(120)
    column transforms
    FILE_DATA FROM LOBFILE (FILE_NM) FROM (dir_data)
    location (dir_data:'files_to_load.dat')
    reject limit 0
    noparallel
    nomonitoring;
    Cheers
    David

  • How to update html file in clob column in oracle

    hi,
    please help me how to update html file in clob column in oracle
    Thanks

    This is your main query as i am able to understand and you want to update your html file into terms columns based on conditions :
    SELECT     b.terms As terms
             FROM chklst_item_x_enrlmnt_type a, prvdr_enrlmnt_agreement b
            WHERE a.enrlmnt_type_cid = 1
              AND a.chklst_item_cid = b.chklst_item_cid
              AND a.chklst_item_cid = 79
              AND a.oprtnl_flag = 'A'
              AND b.oprtnl_flag = 'A'
              AND TRUNC (SYSDATE) BETWEEN b.from_date AND b.TO_DATE;So i suggest below one but you need to create a directory where you can store your html file and then you can update .. And remaining consult Experts suggestions too as your
    question is improperly posted . . .
    DECLARE
       vclob     CLOB;
       v_bfile   BFILE := BFILENAME ('YOUR_DIR', 'filename.html');
    BEGIN
       SELECT     b.terms
             INTO vclob
             FROM chklst_item_x_enrlmnt_type a, prvdr_enrlmnt_agreement b
            WHERE a.enrlmnt_type_cid = 1
              AND a.chklst_item_cid = b.chklst_item_cid
              AND a.chklst_item_cid = 79
              AND a.oprtnl_flag = 'A'
              AND b.oprtnl_flag = 'A'
              AND TRUNC (SYSDATE) BETWEEN b.from_date AND b.TO_DATE
       FOR UPDATE;
       DBMS_LOB.fileopen (v_bfile);
       DBMS_LOB.loadfromfile (vclob, v_bfile, DBMS_LOB.getlength (v_bfile));
       DBMS_LOB.fileclose (v_bfile);
    END;
    / Regards..

  • How to insert more than 32k xml data into oracle clob column

    how to insert more than 32k xml data into oracle clob column.
    xml data is coming from java front end
    if we cannot use clob than what are the different options available

    Are you facing any issue with my code?
    String lateral size error will come when you try to insert the full xml in string format.
    public static boolean writeCLOBData(String tableName, String id, String columnName, String strContents) throws DataAccessException{
      boolean isUpdated = true;
      Connection connection = null;
      try {
      connection = ConnectionManager.getConnection ();
      //connection.setAutoCommit ( false );
      PreparedStatement PREPARE_STATEMENT = null;
      String sqlQuery = "UPDATE " + tableName + " SET " + columnName + "  = ?  WHERE ID =" + id;
      PREPARE_STATEMENT = connection.prepareStatement ( sqlQuery );
      // converting string to reader stream
      Reader reader = new StringReader ( strContents );
      PREPARE_STATEMENT.setClob ( 1, reader );
      // return false after updating the clob data to DB
      isUpdated = PREPARE_STATEMENT.execute ();
      PREPARE_STATEMENT.close ();
      } catch ( SQLException e ) {
      e.printStackTrace ();
      finally{
      return isUpdated;
    Try this JAVA code.

  • Error reading data from CLOB column into VARCHAR2 variable

    Hi all,
    Am hitting an issue retrieving data > 8K (minus 1) stored in a CLOB column into a VARCHAR2 variable in PL/SQL...
    The "problem to be solved" here is storing DDL, in this case a "CREATE VIEW" statement, that is longer than 8K for later retrieval (and execution) using dynamic SQL. Given that the EXECUTE IMMEDIATE statement can take a VARCHAR2 variable (up to 32K(-1)), this should suffice for our needs, however, it seems that somewhere in the process of converting this VARCHAR2 text to a CLOB for storage, and then retrieving the CLOB and attempting to put it back into a VARCHAR2 variable, it is throwing a standard ORA-06502 exception ("PL/SQL: numeric or value error"). Consider the following code:
    set serveroutput on
    drop table test1;
    create table test1(col1 CLOB);
    declare
    cursor c1 is select col1 from test1;
    myvar VARCHAR2(32000);
    begin
    myvar := '';
    for i in 1..8192 loop
    myvar := myvar || 'a';
    end loop;
    INSERT INTO test1 (col1) VALUES (myvar);
    for arec in c1 loop
    begin
    myvar := arec.col1;
    dbms_output.put_line('Read data of length ' || length(myvar));
    exception when others then
    dbms_output.put_line('Error reading data: ' || sqlerrm);
    end;
    end loop;
    end;
    If you change the loop upper bound to 8191, all works fine. I'm guessing this might have something to do with the database character set -- we've recently converted our databases over to UTF-8, for Internationalizion support, and that seems to have changed underlying assumptions regarding character processing...?
    As far as the dynamic SQL issue goes, we can probably use the DBMS_SQL interface instead, with it's EXECUTE procedure that takes a PL/SQL array of varchar2(32K) - the only issue there is reading the data from the CLOB column, and then breaking that data into an array but that doesn't seem insurmountable. But this same basic issue (when a 9K text block, let's say, turns into a >32K block after being CLOBberred) seems to comes up in other text-processing situations also, so any ideas for how to resolve would be much appreciated.
    Thanks for any tips/hints/ideas...
    Jim

    For those curious about this, here's the word from Oracle support (courtesy of Metalinks):
    RESEARCH
    ========
    Test the issue for different DB version and different characterset.
    --Testing the following PL/SQL blocks by using direct assignment method(myvar := arec.col1;) on
    different database version and different characterset.
    SQL>create table test1(col1 CLOB);
    --Inserting four CLOB data into test1.
    declare
    myvar VARCHAR2(32767);
    begin
    myvar := RPAD('a',4000);
    INSERT INTO test1 (col1) VALUES (myvar);
    myvar := RPAD('a',8191);
    INSERT INTO test1 (col1) VALUES (myvar);
    myvar := RPAD('b',8192);
    INSERT INTO test1 (col1) VALUES (myvar);
    myvar := RPAD('c',32767);
    INSERT INTO test1 (col1) VALUES (myvar);
    commit;
    end;
    --Testing the direct assignment method.
    declare
    cursor c1 is select col1, length(col1) len1 from test1;
    myvar VARCHAR2(32767);
    begin
    for arec in c1 loop
    myvar := arec.col1;
    --DBMS_LOB.READ(arec.col1, arec.len1, 1, myvar);
    dbms_output.put_line('Read data of length: ' || length(myvar));
    end loop;
    end;
    The following are the summary of the test results:
    ===================================
    1. If the database characterset is WE8ISO8859P1, then the above direct assignment
    method(myvar := arec.col1;) works for database version 9i/10g/11g without any
    errors.
    2. If the database characterset is UTF8 or AL32UTF8, then the above direct assignment method(myvar := arec.col1;) will generate the "ORA-06502:
    PL/SQL: numeric or value error" when the length of the CLOB data is greater
    than 8191(=8K-1). The same error can be reproduced across all database versions
    9i/10g/11g.
    3. Using DBMS_LOB.READ(arec.col1, arec.len1, 1, myvar) method to read CLOB data into a VARCHAR2 variable works for both WE8ISO8859P1 and UTF8
    characterset and for all database versions.
    So - it seems as I'd surmised, UTF8 changes the way VARCHAR2 and CLOB data is handled. Not too surprising, I suppose - may you all be lucky enough to be able to stay away from this sort of issue. But - the DBMS_LOB.READ workaround is certainly sufficient for the text processing situations we find ourselves in currently.
    Cheers,
    Jim C.

  • Split CLOB column to improve performance

    Hi All,
    We have a transactional table which has 3 columns and one among those is CLOB which holds XML data.Inserts are coming at 35K/hr to this table and data will be deleted as soon as job is completed. So anytime the total records in this table will be less than 1000.
    The XML data contains binary info of images and the size of each XML file ranges any where between 200KB to 600KB and the elapsed time for each insert varies from 1 to 2 secs depending upon the concurrency. As we need to achieve 125K/hour soon we were planning to do few modifications on table level.
    1. Increase the CHUNK size from 8KB to 32KB.
    2. Disabling logging for table,clob and index.
    3. Disable flashback for database.
    4. Move the table to a non default blocksize of 32KB. Default is 8KB
    5. Increase the SDU value.
    6. Split the XML data and store it on multiple CLOB columns.
    We don't do any update to this table. Its only INSERT,SELECT and DELETE operations.
    The major wait events I'm seeing during the insert is
    1. direct path read
    2. direct path write
    3. flashback logfile sync
    4. SQL*Net more data from client
    5. Buffer busy wait
    My doubt over here is ,
    1. If I allocate a 2G memory for the non default block size and change the clob to CACHE, will my other objects in buffer_cache gets affected or gets aged out fast?
    2. And moving this table to a SECUREFILE from BASICFILE will help?
    3. Splitting the XML data to insert into different columns in the same table will give a performance boost?
    Oracle EE 11.2.0.1,ASM
    Thanks,
    Arun

    Thanks to all for the replies
    @Sybrand
    Please answer first whether the column is stored in a separate lobsegment.
    No. Table,Index,LOB,LOB index uses the same TS. I missed adding this point( moving to separate TS) as part of table modifications.
    @Hemant
    There's a famous paper / blog post about CLOBs and Database Flashback. If I find it, I'll post the URL.
    Is this the one you are referring to
    http://laimisnd.wordpress.com/2011/03/25/lobs-and-flashback-database-performance/
    By moving the CLOB column to different block size , I will test the performance improvement it gives and will share the results.
    We dont need any data from this table. XML file contains details about finger prints and once the application server completes the job , XML data is deleted from this table.
    So no need of backup/recovery operations for this table. Client will be able to replay the transactions if any problem occurs.
    @Billy
    We are not performing XML parsing on DB side. Gets the XML data from client -> insert into table -> client selects from table -> Upon successful completion of the Job from client ,XML data gets deleted.
    Regarding binding of LOB from client side, will check on that side also to reduce round trips.
    By changing the blocksize, I can keep db_32K_cache_size=2G and keep this table in CACHE. If I directly put my table to CACHE, it will age out all other operation from buffer which makes things worse for us.
    This insert is part of transaction( Registration of a finger print) and this is the only statement taking time as of now compared to other statements in the transaction.
    Thanks,
    Arun

  • Need to update a single column in a table with some other column value

    Hi experts,
    I was about to change one column data type in a table. Then I renamed that column name to "old_column_name" . Later I added new column name with required datatype( My case its NCLOB). Now I want to update the new column value with old column value.I mean i have to copy the data. But data amount is very huge. Its more than 1.5 crores of data. But on promote day, I have only 1 hr of outage. Please suggest the effective solution to achieve this.

    Hi Stew
    I have 1 primary key in my table and 11 foreign keys in my table.there are 20 check constraints as well.
    If i go for an online redefine of a table, these objects will be created back automatically?
    Please clarify.
    This is my table. Here Remarks is the column with CLOB datatype. To support multi language, I need to change it to NCLOB. That column having data so i cant rename it.
    So I added new column , after renaming that remarks to old_remarks. Now new column remarks is ready with NCLOB data type, but no data in it.
    To copy the old remarks column into new remarks column, i thought to write one script. But how it is achievable using "DBMS_REDEFINITION". Please explain me,
    create table XXXXXXXXXX
    ID NUMBER(8),
    COMPLETED_DATE DATE,
    COMMUNICATION_MEDIUM VARCHAR2(32),
    REMARKS1 VARCHAR2(4000),
    COPY VARCHAR2(1),
    IO_MARKER VARCHAR2(3),
    EVENT_DATE DATE,
    CON_REF_NO NUMBER(8),
    DEP_CODE VARCHAR2(6),
    SFM_STAFF_NO NUMBER(8),
    CRPD_ID NUMBER(8),
    CRPD_ID_COPY NUMBER(8),
    STATUS VARCHAR2(2),
    COMEBACK_NO NUMBER(2),
    ADD_ADD_ID NUMBER(10),
    AEV_ID NUMBER(8),
    OLAY_ID NUMBER(8),
    COE_TYPE VARCHAR2(3),
    CET_CODE VARCHAR2(6),
    DEP_CODE_RAISED_BY VARCHAR2(6),
    SFM_STAFF_NO_RAISED_BY NUMBER(8),
    USR_CREATED VARCHAR2(30),
    CREATED DATE,
    USR_CHANGED VARCHAR2(30),
    CHANGED DATE,
    EXT_REF_ID VARCHAR2(150),
    REPLY_EXPECTED_DATE DATE,
    SEC_ID VARCHAR2(8) not null,
    PROTECTED VARCHAR2(1),
    APPROVED_BY NUMBER(8),
    DOCUMENT BLOB,
    OLD_REMARKS CLOB,
    CTS_ID NUMBER(8),
    MESSAGE_STATUS VARCHAR2(4),
    WORD_DOCUMENT NCLOB,
    REMARKS NCLOB
    Edited by: Hema on Jul 2, 2012 8:31 AM
    Edited by: Hema on Jul 2, 2012 8:31 AM

  • Trying to Insert an XML Element into XML data stored in CLOB column

    Hi all,
    My ORACLE DB version is:
    ('Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production');
    ('PL/SQL Release 11.2.0.2.0 - Production');
    ('CORE 11.2.0.2.0 Production');
    ('TNS for Linux: Version 11.2.0.2.0 - Production');
    ('NLSRTL Version 11.2.0.2.0 - Production');
    I have this XML data stored in a CLOB column:
    <Activity>
         <Changes>     
         </Changes>
         <Inserts>     
         </Inserts>
         <Definition>     
         </Definition>
         <Assignment TYPE="Apply">     
         </Assignment>
         <Spawned>
              <Activity>576D8CD9-57A1-8608-1563-8F6DC74BDF3C</Activity>
              <Activity>11226E79-5D24-02EB-A950-D34A9CCFB3FF</Activity>
              <Activity>DAA68DC0-CA9A-BB15-DE31-9596E19513EE</Activity>
              <Activity>93F667D6-966A-7EAD-9B70-630D9BEFDDD2</Activity>
              <Activity>FA63D9D3-86BB-3FF0-BE69-17EAA7581637</Activity>
         </Spawned>
         <SpawnedBy>AFC49BD4-5AA7-38C0-AE27-F59D16EE1B1C</SpawnedBy>
    </Activity>
    I am in need of some assistance in creating an update that will insert another <Activity>SomeGUID</Activity> into the <Spawned> parent.
    Any help is greatly appreciated.
    Thanks.
    Edited by: 943783 on Dec 14, 2012 12:58 PM

    See XML updating functions : http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb04cre.htm#i1032611
    For example :
    UPDATE my_table t
    SET t.my_clob =
          XMLSerialize(document
            insertChildXML(
              XMLParse(document t.my_clob)
            , '/Activity/Spawned'
            , 'Activity'
            , XMLElement("Activity", 'Some GUID')
    WHERE ...
    ;Although it works, there's overhead introduced by parsing the CLOB, then serializing again.
    Is there any chance you can change the CLOB to SECUREFILE binary XMLType storage instead?
    You would then be able to benefit from optimized piecewise update of the XML and improved storage.

  • Updating a title column in list that is a lookup column to document library in sharepoint designer workflow 2010

    Hi I have a requirement to create a list item in Contracts List when a document is uploaded in Contracts Vendor library.
    Contracts List will
    have  columns - Contract Name ( title column), Contract Number, Contract Start date and end date.
    Contracts Vendor library will have Contract
    Name,Contract NUmber.
    User will select the Contract Name from drop down ( this is look up column linked to Contract Name in Contract
    List).When user uploads document in Contract Vendor library then item should be created in Contract List with selected Contract Name and
    Contract number .
    Contracts and Contracts Vendor are related by look up Contract Name. Contract Name is internally a title column in
    Contracts List.
    Issue1 :
    Since Contract number is look up column, while I am creating item the Contract name is not getting updated in
    Contracts List. I have to use sharepoint designer workflow to achieve this task. Title colum or Contract Name shows no title.
    Issue 2:
    One
    more issue I am facing is that Contracts List has Section and Division cascaded drop downs when i select values from section and division
    dropdowns and save item in Contracts list the values are getting saved in Contract List.
    Could anyone suggest me how to handle this ? I am
    attaching the screenshots of the list and library structure. TRuly appreciate your help.
    Below are screenshots of the list structure

    Hi,
    According to your post, my understanding is that you wanted to update a title column in list that is a lookup column to document library in sharepoint designer workflow 2010.
    I try to reproduce the issues as follows:
    Create a custom list named Contracts List, add columns: Contract Name ( title column), Contract Number(Number), Contract Start date(Data and Time) and Contract End date (Data and Time).
    Create a document library named Contracts Vendor library, add columns: Contract Name(Lookup), Contract NUmber(Lookup).
    Create a workflow associated to the Contracts Vendor library.
    Add action: Create List Item.
       5. Start the workflow automatically when an item is created.
       6. Upload a document, select the Contract Name and Contract NUmber, the workflow will be started automatically.
       7. Open the Contracts List, an item will be added with the Contract Name and Contract Number in the Contracts Vendor library.
    Thank you for your understanding.
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

Maybe you are looking for