XML in clob columns and OWB

I’m building some ETL process to extract data from XML in CLOB columns. I know that there are solutions to use functions as extractvalue() of WB_XML_LOAD(), but I want to know if there is any other way to deal with XML. The reason for that is because my XML files have multiple namespaces and nodes, and I need something more complex to deal with that, since I already tried those two first solutions.
My first solution was to create a PL/SQL that parses the XML and looks for tags and elements. It populates a relational table, and I might use OWB to extract the data from this table. But I’m dealing with a large table and it takes a while for processing, plus my code is hude!
My question is: Does someone have any experience with complex XML in Clob columns? If so, what was your solution for that?
Thanks a lot!
Angelo Buss
[email protected]

CLOB is a fully-updateable, character large object that is stored inside the database. It can be text-indexed using interMedia for document searching.
BFILE is a readonly pointer to a file on the external file system whose content is not physically stored in the database. It can also be text-indexed for document searching, but it can't be updated.

Similar Messages

  • XML Import CLOB column size limit

    I have a table with a CLOB column and some of the rows have up to 7000 characters in the column. I exported the table to XML and the XML file contains all the data. When I try to import the file into another APEX instance I get the error:
    XML Load error.
    After some experimentation, I found that If I manually edit the XML to reduce the size of the text to under 4000 characters (3700 in my test), it imports fine.
    Is there a way around this limitation? The database I'm migrating has LOTS of CLOB columns (converted from MS Access "memo" fields).

    jlange,
    Having converted a bunch of MS Access applications myself, I would encourage you to look at the Oracle Migration Workbench (OMWB): http://www.oracle.com/technology/tech/migration/index.html
    This free tool can be downloaded from OTN, and provides a more streamlined approach to moving the data from MS Access to Oracle, including support for Memos to CLOBs.
    Once you're data has been moved over, you can then use ApEx to re-create the UI.
    Thanks,
    - Scott -

  • Select fields from XML in CLOB column

    Hi,
    I have the following XML stored in a table as CLOB field. What i want is to select specific fields into Relational Data.
    <?xml version=1.0 encoding=UTF-8?>
    <msgContext>
        <JMSHeaders xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">
            <jms1:JMSDeliveryMode>PERSISTENT</jms1:JMSDeliveryMode>
            <jms1:JMSTimestamp>1329217943352</jms1:JMSTimestamp>
            <jms1:JMSExpiration>0</jms1:JMSExpiration>
            <jms1:JMSRedelivered>false</jms1:JMSRedelivered>
            <jms1:JMSPriority>4</jms1:JMSPriority>
        </JMSHeaders>
        <OtherProperties>
            <auditPartnerId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">010000000001189CC2BC2C</auditPartnerId>
            <auditServiceId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">Auth</auditServiceId>
            <correlationTransactionId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">d0022064-1df3-43ef-be5b-93aedc96b3b2</correlationTransactionId>
            <auditReceivedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.346 +0100</auditReceivedDate>
            <auditStatus xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">ok</auditStatus>
            <auditForwardedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.351 +0100</auditForwardedDate>
            <auditMsisdn xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms"/>
            <auditEngineId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">dpNorthLog</auditEngineId>
            <ns0:auditInfo xmlns:ns0="http://www.tibco.com/schemas/Project_gig_reporting/tib_bw_reporting/Resources/Schemas/auditInfo.xsd">
                <ns0:dp-logpoint>response</ns0:dp-logpoint>
                <ns0:dp-target-url/>
                <ns0:dp-port>20565</ns0:dp-port>
                <ns0:dp-uri>/comp_am</ns0:dp-uri>
                <ns0:dp-size>1365</ns0:dp-size>
                <ns0:dp-replytoengine/>
            </ns0:auditInfo>
        </OtherProperties>
    </msgContext>I tried to use the xml_query below with no luck :
    SELECT  x.auditPartnerId,
                 x.auditServiceId
       FROM source s
         , XMLTable(
             '/msgContext/OtherProperties'
              passing s.messagetext
              columns
              auditPartnerId   VARCHAR2(20) PATH 'auditPartnerId'
            , auditServiceId     VARCHAR2(20) PATH 'auditServiceId'
            ) x;Any help appreciated

    alekons wrote:
    Any help appreciatedYou will have to convert it to xmltype first. See below:
    SQL> select * from v$version ;
    BANNER
    Oracle Database 10g Release 10.2.0.5.0 - Production
    PL/SQL Release 10.2.0.5.0 - Production
    CORE     10.2.0.5.0     Production
    TNS for Linux: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production
    SQL> with src as ( select to_clob('<msgContext>
    <JMSHeaders xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">
    <jms1:JMSDeliveryMode>PERSISTENT</jms1:JMSDeliveryMode>
    <jms1:JMSTimestamp>1329217943352</jms1:JMSTimestamp>
    <jms1:JMSExpiration>0</jms1:JMSExpiration>
    <jms1:JMSRedelivered>false</jms1:JMSRedelivered>
    <jms1:JMSPriority>4</jms1:JMSPriority>
    </JMSHeaders>
    <OtherProperties>
    <auditPartnerId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">010000000001189CC2BC2C</auditPartnerId>
    <auditServiceId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">Auth</auditServiceId>
    <correlationTransactionId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">d0022064-1df3-43ef-be5b-93aedc96b3b2</correlationTransactionId>
    <auditReceivedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.346 +0100</auditReceivedDate>
    <auditStatus xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">ok</auditStatus>
    <auditForwardedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.351 +0100</auditForwardedDate>
    <auditMsisdn xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms"/>
    <auditEngineId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">dpNorthLog</auditEngineId>
    <ns0:auditInfo xmlns:ns0="http://www.tibco.com/schemas/Project_gig_reporting/tib_bw_reporting/Resources/Schemas/auditInfo.xsd">
    <ns0:dp-logpoint>response</ns0:dp-logpoint>
    <ns0:dp-target-url/>
    <ns0:dp-port>20565</ns0:dp-port>
    <ns0:dp-uri>/comp_am</ns0:dp-uri>
    <ns0:dp-size>1365</ns0:dp-size>
    <ns0:dp-replytoengine/>
    </ns0:auditInfo>
    </OtherProperties>
    </msgContext>') as messagetext from dual )
    SELECT x.auditPartnerId,
    x.auditServiceId
    FROM src s
    , XMLTable(
    '/msgContext/OtherProperties'
    passing s.messagetext
    columns
    auditPartnerId VARCHAR2(20) PATH 'auditPartnerId'
    , AUDITSERVICEID VARCHAR2(20) PATH 'auditServiceId'
    ) x;
    36   37  passing s.messagetext
    ERROR at line 33:
    ORA-00932: inconsistent datatypes: expected - got CLOB
    with src as ( select xmltype(to_clob('<msgContext>
    <JMSHeaders xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">
    <jms1:JMSDeliveryMode>PERSISTENT</jms1:JMSDeliveryMode>
    <jms1:JMSTimestamp>1329217943352</jms1:JMSTimestamp>
    <jms1:JMSExpiration>0</jms1:JMSExpiration>
    <jms1:JMSRedelivered>false</jms1:JMSRedelivered>
    <jms1:JMSPriority>4</jms1:JMSPriority>
    </JMSHeaders>
    <OtherProperties>
    <auditPartnerId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">010000000001189CC2BC2C</auditPartnerId>
    <auditServiceId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">Auth</auditServiceId>
    <correlationTransactionId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">d0022064-1df3-43ef-be5b-93aedc96b3b2</correlationTransactionId>
    <auditReceivedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.346 +0100</auditReceivedDate>
    <auditStatus xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">ok</auditStatus>
    <auditForwardedDate xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">2012-02-14 12:12:23.351 +0100</auditForwardedDate>
    <auditMsisdn xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms"/>
    <auditEngineId xmlns:jms1="http://www.tibco.com/namespaces/tnt/plugins/jms">dpNorthLog</auditEngineId>
    <ns0:auditInfo xmlns:ns0="http://www.tibco.com/schemas/Project_gig_reporting/tib_bw_reporting/Resources/Schemas/auditInfo.xsd">
    <ns0:dp-logpoint>response</ns0:dp-logpoint>
    <ns0:dp-target-url/>
    <ns0:dp-port>20565</ns0:dp-port>
    <ns0:dp-uri>/comp_am</ns0:dp-uri>
    <ns0:dp-size>1365</ns0:dp-size>
    <ns0:dp-replytoengine/>
    </ns0:auditInfo>
    </OtherProperties>
    </msgContext>')) as messagetext from dual )
    SELECT x.auditPartnerId,
    x.auditServiceId
    FROM src s
    , XMLTable(
    '/msgContext/OtherProperties'
    passing s.messagetext
    columns
    auditPartnerId VARCHAR2(20) PATH 'auditPartnerId'
    , AUDITSERVICEID VARCHAR2(20) PATH 'auditServiceId'
    37  ) x;
    AUDITPARTNERID          AUDITSERVICEID
    010000000001189CC2BC Auth

  • Load XML to CLOB column

    i want to load xml file to a column with CLOB datatype.
    I can do it with the help of tools like TOAD etc but i want to do through sql or pl/sql.
    Can anybody can help on this?

    Check this.
    http://www.oracle.com/technology/sample_code/tech/java/codesnippet/xmldb/HowToLoadLargeXML.html#PLSQLCode
    Regards
    Sundar

  • Query data on an XML table CLOB

    Hi
    I'd like to query an Oracle table to extract xml attributes on xml CLOB column's please see below table structure and how can i improve performance on this table we've already created Index.
    Can you please assist on how to improve performance when querying this table and is there a better way of Querying this table??
    Any suggestion's a welcomed.
    DB version: 11.2.0.1.0
    Table Structure
    CREATE TABLE XXCUSTOM.XXWSF_AR_INTEGRATION_LOG
      ID              NUMBER,
      TIME_RECIEVED   DATE                          DEFAULT SYSDATE,
      INPUT_MESSAGE   CLOB,
      RETURN_MESSAGE  CLOB
    CREATE INDEX APPS.TIME_RECEIVED_IDX ON XXCUSTOM.XXWSF_AR_INTEGRATION_LOG
    (TIME_RECIEVED)
    CREATE UNIQUE INDEX XXCUSTOM.XXWSF_AR_INTEGRATION_LOG_PK ON XXCUSTOM.XXWSF_AR_INTEGRATION_LOG
    (ID)This is my xml on my input_message CLOB column and this table contain more that *700,000 records(row)*
    <AR-Message-Customer arDocumentPrimaryKey="5634300">
    <Customer Customer-Number="AUDJOH0000002" Cusomter-Name="AUDI JOHANNESBURG " Address-1="55 BERTHA STREET " Address-2=" " Address-3="BRAAMFONTEIN " Postal-Code="2017" City-Or-Town="JOHANNESBURG " Country="ZAF" Bank-Name="FIRST NATIONAL BANK " Bank-Account-Num="62116103988" Bank-Account-Description="WSF" Bank-Account-Name="BRETT HUDSON (PTY) LTD " Branch-Name="JOHANNESBURG BRANCH " Branch-Num="251305" Bank-Account-Start-Date="09/08/13 00:00" Org-Id="3010" Customer-Site-Name="34322">
    <Invoice-Lines Customer-Number="AUDJOH0000002" Amount="4457.83" Amount-Includes-Tax-FLag="N" Currency-Code="ZAR" Document-Number="5634285" Invoice-Number="5634285" Invoice-Date="2011-03-31" Line-Number="1" Line-Type="LINE" Org-Id="3010" Quantity="1" Tax-Code="EXEMPT" Tax-Rate="0" Payment-Method="INTERNAL_TRANSFER" Company="3010" R-Company="3010" Joint-Venture="WB" R-Joint-Venture="00000" Contract="X11471=4" R-Contract="0000000" R-Dealer="AUDJOH0000002" Cost-Centre="1370000" R-Cost-Centre="1370000" Account-Code="4317301" R-Account-Code="1317310" Supplier="AUDJOH0000002" Dealer="AUDJOH0000002" Create-Invoice-Flag="N" R-Supplier="AUDJOH0000002" Customer-Site-Name="34322"/>
    <Invoice-Lines Customer-Number="AUDJOH0000002" Amount="0.00" Amount-Includes-Tax-FLag="N" Currency-Code="ZAR" Document-Number="5634285" Invoice-Number="5634285" Invoice-Date="2011-03-31" Line-Number="2" Line-Type="TAX" Link-To-Line-Attribute1="1" Org-Id="3010" Quantity="1" Tax-Code="EXEMPT" Tax-Rate="0" Payment-Method="INTERNAL_TRANSFER" Company="3010" R-Company="3010" Joint-Venture="WB" R-Joint-Venture="00000" Contract="X11471=4" R-Contract="0000000" R-Dealer="AUDJOH0000002" Cost-Centre="1370000" R-Cost-Centre="1370000" Account-Code="2221675" R-Account-Code="2221675" Supplier="AUDJOH0000002" Dealer="AUDJOH0000002" Create-Invoice-Flag="N" R-Supplier="AUDJOH0000002" Customer-Site-Name="34322"/>
    <Invoice-Lines Customer-Number="AUDJOH0000002" Amount="2113.16" Amount-Includes-Tax-FLag="N" Currency-Code="ZAR" Document-Number="5634285" Invoice-Number="5634285" Invoice-Date="2011-03-31" Line-Number="3" Line-Type="LINE" Org-Id="3010" Quantity="1" Tax-Code="EXEMPT" Tax-Rate="0" Payment-Method="INTERNAL_TRANSFER" Company="3010" R-Company="3010" Joint-Venture="WB" R-Joint-Venture="00000" Contract="X27206=3" R-Contract="0000000" R-Dealer="AUDJOH0000002" Cost-Centre="1370000" R-Cost-Centre="1370000" Account-Code="4317301" R-Account-Code="1317310" Supplier="AUDJOH0000002" Dealer="AUDJOH0000002" Create-Invoice-Flag="N" R-Supplier="AUDJOH0000002" Customer-Site-Name="34322"/>
    </Customer>
    </AR-Message-Customer>I'm currently using the below Query but it's not helpful in terms of perfomance.
    select id,extractValue(value(line),'/Invoice-Lines/@Amount') line_Amount,
           extractValue(value(line),'/Invoice-Lines/@Amount-Includes-Tax-FLag') Amount_Includes_Tax_FLag,
           extractValue(value(line),'/Invoice-Lines/@Currency-Code') Currency_Code,
           extractValue(value(line),'/Invoice-Lines/@Document-Number') Document_Number,
           extractValue(value(line),'/Invoice-Lines/@Invoice-Number') Invoice_Number,
           extractValue(value(line),'/Invoice-Lines/@Invoice-Date') Invoice_Date,
           extractValue(value(line),'/Invoice-Lines/@Line-Number') Line_Number,
           extractValue(value(line),'/Invoice-Lines/@Line-Type') Line_Type,
           extractValue(value(line),'/Invoice-Lines/@Link-To-Line-Attribute1') Link_To_Line_Attribute1,
           extractValue(value(line),'/Invoice-Lines/@Org-Id') Org_Id,
           extractValue(value(line),'/Invoice-Lines/@Tax-Code') Tax_Code,
           extractValue(value(line),'/Invoice-Lines/@Tax-Excempt-Flag') Tax_Excempt_Flag,
           extractValue(value(line),'/Invoice-Lines/@Tax-Excempt-Number') Tax_Excempt_Number,
           extractValue(value(line),'/Invoice-Lines/@Tax-Excempt-Reason-Code') Tax_Excempt_Reason_Code,
           extractValue(value(line),'/Invoice-Lines/@Tax-Rate') Tax_Rate,
           extractValue(value(line),'/Invoice-Lines/@Payment-Method') Payment_Method,
           extractValue(value(line),'/Invoice-Lines/@Company') Company,
           extractValue(value(line),'/Invoice-Lines/@R-Company') R_Company,
           extractValue(value(line),'/Invoice-Lines/@Joint-Venture') Joint_Venture,
           extractValue(value(line),'/Invoice-Lines/@R-Joint-Venture') R_Joint_Venture,
           extractValue(value(line),'/Invoice-Lines/@Contract') Contract,
           extractValue(value(line),'/Invoice-Lines/@R-Contrac') R_Contrac,
           extractValue(value(line),'/Invoice-Lines/@R-Dealer') R_Dealer,
           extractValue(value(line),'/Invoice-Lines/@Cost-Centre') Cost_Centre,
           extractValue(value(line),'/Invoice-Lines/@R-Cost-Centre') R_Cost_Centre,
           extractValue(value(line),'/Invoice-Lines/@Account-Code') Account_Code,
           extractValue(value(line),'/Invoice-Lines/@R-Account-Code') R_Account_Code,
           extractValue(value(line),'/Invoice-Lines/@Supplier') Supplier,
           extractValue(value(line),'/Invoice-Lines/@Dealer') Dealer,
           extractValue(value(line),'/Invoice-Lines/@Create-Invoice-Flag') Create_Invoice_Flag,
           extractValue(value(line),'/Invoice-Lines/@R-Supplier') R_Supplier
    from XXWSF_AR_INTEGRATION_LOG a,
         table(XMLSequence(extract(xmltype(input_message),'/AR-Message-Customer/Customer/Invoice-Lines'))) line
    where id = 4123;Thanks
    Lethu

    I'm currently using the below Query but it's not helpful in terms of perfomance.How do you measure "performance"? Response time? System resources used?
    What performance are you expecting vs. what you're currently observing?
    If you're always accessing the table through its unique index, there shouldn't be any performance issue in accessing the table.
    Is the XML you posted a typical document you have in the table? In terms of size?
    Parsing a document that small shouldn't be an issue either whatever the method used.
    Anyway, as Alex said, an optimal storage model would use an XMLType column (binary XML or schema-based object-relational model) instead of CLOB.

  • Best Way to Drop Large Clob Column?

    I have a very large partitioned table that contains XML documents stored in a clob column. Aside from the clob column there are several varchar and numeric columns in the table that are related to each document. We have decided to move the XML out of Oracle and into text files on the OS but want to keep the other data in Oracle. Each partition has a tablespace for the clob column and a tablespace for the other columns.
    What is the best (quickest/most efficient) way to drop the clob column and free up the space that it is currently using?
    OS: HP-UX
    Oracle: 11.2.0.3
    Table Partitions: 27
    Table Rows: 550,000,000
    Table Size: around 15 TB with 95% of that found in the column to drop
    One other wrinkle, there are several tables that have a foreign key relationship back to the primary key of the table in question. Three of those tables are multi-billion rows in size.

    Hi,
    You can use the mark unused column,and checkpoint in the drop column statements,
    please visit the link. may it help you
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:623063677753

  • 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.

  • How to insert data into a CLOB column

    In UIX XML I used a bc4j:textInput control for a CLOB column and I cannot type any letter in this field....Why ?
    Regards,
    Lucian

    Hello again !
    Here are my findings (Content is a CLOB column; I use UIX XML + BC4J):
    1.If I put:
    <inlineMessage prompt="Content" required="no" vAlign="middle" >
    <contents>
    <bc4j:textInput name="Content" attrName="Content" columns="162" rows="5" />
    </contents>
    </inlineMessage>
    I cannot type any letter in the text Input field !!!!!!
    2. If I put
    <inlineMessage prompt="Content" required="no" vAlign="middle" >
    <contents>
    <bc4j:attrScope name="Content">
    <contents>
    <textInput name="Content" columns="162" rows="5">
    <boundAttribute name="text">
    <bc4j:attrProperty name="value"/>
    </boundAttribute>
    </textInput>
    </contents>
    </bc4j:attrScope>
    </contents>
    </inlineMessage>
    I can type in the textInput field, but I cannot save the text after a certain number of characters. Also I cannot see the saved text. I receive :
    Servlet error: Renderer failed: java.lang.ArrayIndexOutOfBoundsException: -35</PRE></BODY></HTML>
    inside the textInput field.
    Please help me ...
    Regards,
    Lucian

  • 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.

  • Can clob columns be selected across a database link (synonym)?

    Hello,
    I would like to do something like this...
    insert into archive_table (id, msg, start_date)
    select id, msg, startdate from synonym_table
    where start_date < whatever;
    ...where msg represents a clob column and synonym_table represents a synonym in the current table space which accesses another Oracle table using a database link.
    Is this possible?

    http://asktom.oracle.com/pls/ask/f?p=4950:8:15261108079829288196::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:950029833940

  • Slow delete on a table with one CLOB column

    Hi,
    I have a table which has one CLOB column and even if I delete one row from it, it takes approx. 16 seconds. Since UNDO isn't generated for CLOBs (at least not in the UNDO tablespace), I can't figure out why this is so? The CLOB has defined a RETENTION clause, so it depends upon UNDO_RETENTION which is set to 900. There wasn't any lock from another session present on this table.
    The table currently contains only 6 rows but it used to be bigger in the past, so I thought that maybe a full table scan is going on when deleting. But even if I limit the DELETE statement with an ROWID (to avoid a FTS), it doesn't help:
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL Release 11.1.0.6.0 - Production
    CORE    11.1.0.6.0      Production
    TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production
    SQL> select count(*) from scott.packet;
      COUNT(*)
             6
    SQL> column segment_name format a30
    SQL> select segment_name
      2    from dba_lobs
      3  where owner = 'SCOTT'
      4     and table_name = 'PACKET';
    SEGMENT_NAME
    SYS_LOB0000081487C00002$$
    SQL>  select segment_name, bytes/1024/1024 MB
      2    from dba_segments
      3  where owner = 'SCOTT'
      4      and segment_name in ('PACKET', 'SYS_LOB0000081487C00002$$');
    SEGMENT_NAME                           MB
    PACKET                               ,4375
    SYS_LOB0000081487C00002$$             576
    SQL> -- packet_xml is the CLOB column
    SQL> select sum(dbms_lob.getlength (packet_xml))/1024/1024 MB from scott.packet;
            MB
    19,8279037
    SQL> column rowid new_value rid
    SQL> select rowid from scott.packet where rownum=1;
    ROWID
    AAAT5PAAEAAEEDHAAN
    SQL> set timing on
    SQL> delete from scott.packet where rowid = '&rid';
    old   1: delete from scott.packet where rowid = '&rid'
    new   1: delete from scott.packet where rowid = 'AAAT5PAAEAAEEDHAAN'
    1 row deleted.
    Elapsed: 00:00:15.64From another session I monitored v$session.event for the session performing the DELETE and the reported wait event was 'db file scattered read'.
    Someone asked Jonathan Lewis a similar looking question (under comment #5) here: http://jonathanlewis.wordpress.com/2007/05/11/lob-sizing/ but unfortunately I couldn't find if he wrote any answer/note about that.
    So if anyone has any suggestion, I'll appreciate it very much.
    Regards,
    Jure

    After reviewing the tkprof as suggested by user503699, I noticed that the DELETE itself is instantaneous. The problem is another statement:
    select /*+ all_rows */ count(1)
    from
    "SCOTT"."MESSAGES" where "PACKET_ID" = :1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          2           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      1.40      16.93     125012     125128          0           1
    total        3      1.40      16.93     125012     125128          2           1
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: SYS   (recursive depth: 1)
    Rows     Row Source Operation
          1  SORT AGGREGATE (cr=125128 pr=125012 pw=125012 time=0 us)
          0   TABLE ACCESS FULL MESSAGES (cr=125128 pr=125012 pw=125012 time=0 us cost=32900 size=23056 card=5764)I checked if there was any "ON DELETE" trigger and since there wasn't, I suspected this might be a problem of unindexed foreign keys. As soon as I created an index on SCOTT.MESSAGES.PACKET_ID the DELETE executed immediately. The "funny" thing is that, the table SCOTT.MESSAGES is empty, but it has allocated 984MB of extents (since it wasn't truncated), so a time consuming full tablescan was occurring on it.
    Thanks for pointing me to the 10046 trace which solved the problem.
    Regards,
    Jure

  • How to retreive soap xml data from clob column in a table

    Hi,
    I am trying to retrieve the XML tag value from clob column.
    Table name = xyz and column= abc (clob datatype)
    data stored in abc column is as below
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:head="http://www.abc.com/gcgi/shared/system/header" xmlns:v6="http://www.abc.com/gcgi/services/v6_0_0_0" xmlns:sys="http://www.abc.com/gcgi/shared/system/systemtypes">
    <soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
    <RqHeader soapenv:mustUnderstand="0" xmlns="http://www.abc.com/gcgi/shared/system/header">
    <DateAndTimeStamp>2011-12-20T16:02:36.677+08:00</DateAndTimeStamp>
    <UUID>1000002932</UUID>
    <Version>6_0_0_0</Version>
    <ClientDetails>
    <Org>ABC</Org>
    <OrgUnit>ABC</OrgUnit>
    <ChannelID>HBK</ChannelID>
    <TerminalID>0000</TerminalID>
    <SrcCountryCode>SG</SrcCountryCode>
    <DestCountryCode>SG</DestCountryCode>
    <UserGroup>HBK</UserGroup>
    </ClientDetails>
    </RqHeader>
    <wsa:Action>/SvcImpl/bank/
    SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq</wsa:Action></soapenv:Header>
    <soapenv:Body>
    <v6:AlertDeleteInqRq>
    <v6:Base>
    <v6:VID>20071209013112</v6:VID>
    <!--Optional:-->
    <v6:Ref>CTAA00000002644</v6:Ref>
    </v6:Base>
    </v6:AlertDeleteInqRq>
    </soapenv:Body>
    </soapenv:Envelope>
    And i want to retrieve the values of tag
    <ChannelID> and <v6:VID>
    can somebody help, i have tried with extractvalue but not able to get the values

    I have used the below two queries but not able to get the expected results. Both queries result into no values.
    select xmltype(MED_REQ_PAYLOAD).extract('//ClientDetails/Org','xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" || xmlns="http://www.abc.com/gcgi/shared/system/header"').getStringValue() from ESB_OUTPUT_TEMP where SOAPACTION = '/SvcImpl/bank/alerts/v6_0_0_0/SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq'
    select EXTRACTVALUE(xmltype(MED_REQ_PAYLOAD),'/RqHeader/) from ESB_OUTPUT_TEMP where SOAPACTION = '/SvcImpl/bank/SOAPEndpoint/AlertsService.serviceagent/OpEndpointHTTP/AlertDeleteInq'
    Well, for starters, both queries are syntactically wrong :
    - non terminated string
    - incorrect namespace mapping declaration
    - unknown XMLType method "getStringValue()"
    Secondly, all those functions are deprecated now.
    Here's an up-to-date example using XMLTable. It will retrieve the two tag values you mentioned :
    SQL> select x.*
      2  from esb_output_temp t
      3     , xmltable(
      4         xmlnamespaces(
      5           'http://schemas.xmlsoap.org/soap/envelope/' as "soap"
      6         , 'http://www.abc.com/gcgi/shared/system/header' as "head"
      7         , 'http://www.abc.com/gcgi/services/v6_0_0_0' as "v6"
      8         )
      9       , '/soap:Envelope'
    10         passing xmlparse(document t.med_req_payload)
    11         columns ChannelID  varchar2(10) path 'soap:Header/head:RqHeader/head:ClientDetails/head:ChannelID'
    12               , VID        varchar2(30) path 'soap:Body/v6:AlertDeleteInqRq/v6:Base/v6:VID'
    13       ) x
    14  ;
    CHANNELID  VID
    HBK        20071209013112
    You may also want to store XML in XMLType columns for both performance and storage optimizations.

  • 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.

  • Reading Xml file from clob column in the staging table

    Hi,
    I am trying to poll the staging table with the database adapter which has CLOB column type containing XML file. How do I extract the XML file from CLOB and map the fields to the another variable with definite schema.
    Thanks,
    Edited by: chaitu123 on Sep 20, 2009 8:16 AM

    1) when you create DBAdapter on a table which having the clob column watch closely the created xsd for the DBAdapter the clob cloumn element should be a String data type
    2) create xsd for Xml File and create variable for the xsd element
    3) use ora:parseEscapedXML("yourDBAdapterclobElement") to XmlFileVarilable
    Krishna

  • Storing and searching XML in CLOBs

    Speaking to an oracle employee at the Oracle booth at JavaOne
    recently. They suggested I store XML in CLOBs
    and use the DOM or SAX to reparse the XML later as needed.
    I agreed that this was the best solution for my problem
    (which was how to manage many different XML documents using many
    different DTDs in a document management system)
    The big problem was searching this document repository
    to locate relevant information.
    This is where Intermedia seemed ideal (still does).
    It would be nice to see an example of setting this up using
    Intermedia in Oracle 8i, demonstrating how to define the
    XML_SECTION_GROUP and where to use a ZONE as opposed to a FIELD
    etc.
    Anybody care to take a shot at this ????
    For example:
    How would I define Intermedia parameters
    so that I would be able to search my CLOB
    column for records that had the <keyword>
    "aorta" and "damage" in the <caption>
    using the following
    XML (DTD implied)
    <image filename="OurImageName.gif">
    <fname>WellKnownFileName.gif</fname>
    <keyword>echocardiogram</keyword>
    <keyword>aorta</keyword>
    <caption>This is an image of the vessel damage</caption>
    </image>
    Thanks
    Thomas Bennett
    null

    Eric (guest) wrote:
    : You can't do XML structure-based searches with intermedia. You
    : can search for text within a given element, but nothing more
    : complicated than that.
    The example he gave involves exactly that -- searching for
    text within XML elements. interMedia can do this.
    : It also does not do attributes.
    Upcoming 8.1.6 version allows searching within
    attribute text. That's something like:
    dog within book@author
    We're working on attribute value sensitive search,
    more like:
    dog within book[@author = "Eric"]
    : Thomas Bennett (guest) wrote:
    : : How would I define Intermedia parameters
    : : so that I would be able to search my CLOB
    : : column for records that had the <keyword>
    : : "aorta" and "damage" in the <caption>
    : : using the following
    : : XML (DTD implied)
    : : <image filename="OurImageName.gif">
    : : <fname>WellKnownFileName.gif</fname>
    : : <keyword>echocardiogram</keyword>
    : : <keyword>aorta</keyword>
    : : <caption>This is an image of the vessel damage</caption>
    : : </image>
    begin
    ctx_ddl.create_section_group('mygrp','basic_section_group');
    ctx_ddl.add_field_section('mygrp','keyword','keyword');
    ctx_ddl.add_field_section('mygrp','caption','caption');
    end;
    create index myidx on mytab(mytxtcolumn)
    indextype is ctxsys.context
    parameters ('section group mygrp');
    select * from mytab
    where contains(mytxtcolumn, 'aorta within keyword')>0;
    options:
    * use XML section group instead of basic section group
    if your tags have attributes or you need case-sensitive
    tag detection
    * use zone sections instead of field sections if your
    sections overlap, or if you need to distinguish
    between instances. For instance, keywords. If keywords
    is a field section, then
    (aorta and echocardiogram) within keywords
    finds the document. if it is a zone section, then it
    doesn't, because they are not in the SAME instance of
    keywords.
    null

Maybe you are looking for

  • Encoding Dolby Digital 5.1 (AC3) sound in MP4 files using AC3 pass-through

    Looking for an application that will encode Dolby Digital 5.1 (AC3) sound in an .mp4 container using AC3 pass-through for playing videos with surround sound on ATV. Handbrake is out of the question because I run Tiger. The Tiger version cannot do AC3

  • What is the use of AET? What are the differences between AET and EEWB?

    Hi, I would like to know about AET? What is the use of AET? What are the differences between AET and EEWB? Please help me out? Thanks, Satish

  • Update catalog with new files ? - LR 2.2

    I have imported all my files/folders into catalogs in LR2.2 But if I add new files to a folder, the files do not show up in LR. I guess I have to update/refresh the catalog but how do I do this ? Do I have to import the folder again, to get all the n

  • Launchpad stopped working

    I set Launchpad to show using F6 in the keyboard shortcuts part of prefrences. It worked for a day and a half but now it wants to launch Mission Control. When I try to reset the key to another key such as F1 it gives me the alert sound. I went to ano

  • Best way to monitor audio for web

    99%of my projects are for the web and I've been using studio headphones to monitor my audio levels and balances but lately I've noticed that the headphones may be too precise. Fine tuning balances for reproduction with quality headphones. Now I've be