CLOB Vs XMLTYPE

Hi Guys,
In one of my applications , From the front end we are getting XML data and storing the xml data in the col of table which is CLOB type .
Today one of the application developer told that directly we can store the xml data into the data base.Could any one tell me the difference in storing the data in the clob and xml
and also what is the advantages of using xml over clob data type.
Any suggestions will be highly appreciated.
Thanks,
Prafulla

Prafulla wrote:
Hi Guys,
In one of my applications , From the front end we are getting XML data and storing the xml data in the col of table which is CLOB type .
Today one of the application developer told that directly we can store the xml data into the data base.Could any one tell me the difference in storing the data in the clob and xml
and also what is the advantages of using xml over clob data type.
Any suggestions will be highly appreciated.
Thanks,
PrafullaXMLTYPE is based on the CLOB datatype under the hood. CLOB simply stores a whole stream of characters in one large chunk and you need to use the DBMS_LOB package to pull out any sort of structured information from that CLOB. XMLTYPE on the other hand understands that the content is XML and provides various methods for accessing the data as well as SQL being able to access the XML in a structured manner too.
For example, if you have some XML in an XMLTYPE, you can use the XMLTABLE keyword in SQL to extract the data from it e.g..
WITH t as (select XMLTYPE('
<RECSET>
  <REC>
    <COUNTRY>1</COUNTRY>
    <POINT>1800</POINT>
    <USER_INFO>
      <USER_ID>1</USER_ID>
      <TARGET>28</TARGET>
      <STATE>6</STATE>
      <TASK>12</TASK>
    </USER_INFO>
    <USER_INFO>
      <USER_ID>5</USER_ID>
      <TARGET>19</TARGET>
      <STATE>1</STATE>
      <TASK>90</TASK>
    </USER_INFO>
  </REC>
  <REC>
    <COUNTRY>2</COUNTRY>
    <POINT>2400</POINT>
    <USER_INFO>
      <USER_ID>3</USER_ID>
      <TARGET>14</TARGET>
      <STATE>7</STATE>
      <TASK>5</TASK>
    </USER_INFO>
  </REC>
</RECSET>') as xml from dual)
-- END OF TEST DATA
select x.country, x.point, y.user_id, y.target, y.state, y.task
from t
    ,XMLTABLE('/RECSET/REC'
              PASSING t.xml
              COLUMNS country NUMBER PATH '/REC/COUNTRY'
                     ,point   NUMBER PATH '/REC/POINT'
                     ,user_info XMLTYPE PATH '/REC/*'
             ) x
    ,XMLTABLE('/USER_INFO'
              PASSING x.user_info
              COLUMNS user_id NUMBER PATH '/USER_INFO/USER_ID'
                     ,target  NUMBER PATH '/USER_INFO/TARGET'
                     ,state   NUMBER PATH '/USER_INFO/STATE'
                     ,task    NUMBER PATH '/USER_INFO/TASK'
             ) y
   COUNTRY      POINT    USER_ID     TARGET      STATE       TASK
         1       1800          1         28          6         12
         1       1800          5         19          1         90
         2       2400          3         14          7          5It uses XQuery expressions to reference the data, so you can reference attributes of the XML elements as well as their values, and you can also use namespaces if those are needed. The above is just a simple example with some nested repeating groups.
If you tried to extract that data using a CLOB, you'd struggle to do that in SQL easily.

Similar Messages

  • Convert clob to xmltype

    Hi
    How to convert data CLOB datatype to XMLTYPE Datatype
    Ex: field col1 has clob data type
    any possible to convert col1 in target table col1 xmltype datatype
    Regards,
    Venkat

    Hi Venkat,
    Please try the following:
    CREATE TABLE CLOBTABLE (
    CLOBCOL1 CLOB
    INSERT INTO clobtable VALUES ('<?xml version="1.0"?> <EMP> <EMPNO>2</EMPNO> <ENAME>Sumeet</ENAME> </EMP>');
    CREATE OR REPLACE FUNCTION to_xmltype (clobcol CLOB) RETURN XMLTYPE AS
    BEGIN
    RETURN XMLType(clobcol);
    END;
    SELECT to_xmltype(clobcol) FROM clobtab;

  • Convert CLOB to XMLType in SELECT statement ?

    Hi XML Xperts,
    In my Oracle 9.2.0.3 I have 1 table (tab1) with 2 cols (col1 as XMLType and col2 as CLOB). I Inserted in both fields the following same XML data :
    <?xml version="1.0"?>
    <TABLE_NAME>MY_TABLE</TABLE_NAME>
    With the following statement, I can get the data from col1 which is a XMLType column :
    SELECT a.col1.extract('//TABLE_NAME/text()').getStringVal() AS "Table Name"
    FROM tab1 a
    WHERE a.col1.existsNode('/TABLE_NAME') = 1;
    How to get the same data FROM col2 whcih is a CLOB column ? Is it possible to transform the CLOB to XMLType in the SELECT statement ?
    Note : I cannot change the type of the colulmn col2 to XMLType
    Thanks in advance.
    Phil

    I tested it in 10g and it seems to be OK.
    create table clobtoxml(xmldata clob);
    insert into clobtoxml
    values('<RootE><FirstNode>This is CLOB data to XML</FirstNode></RootE>');
    commit;
    select sys.xmltype(xmldata).extract('/RootE/FirstNode/text()').getStringVal() from clobtoxml;
    This is CLOB data to XML
    select sys.xmltype(xmldata).extract('/*') from clobtoxml;
    <RootE>
    <FirstNode>This is CLOB data to XML</FirstNode>
    </RootE>
    Ben

  • How to convert CLOB to XMLType ??

    Hi,
    I created a table XML_TAB as
    SQL> desc xml_tab;
    Name Null? Type
    DOCID NUMBER
    DTD CLOB
    XMLDOC CLOB
    VALID NUMBER
    and I inserted a record in the table.
    Now the file inserted at the column XMLDOC, I want to convert it to XMLType. How can I do that.
    Some docs says to user XMLType.createXML function......
    But when I did it....................
    SQL> select xmltype.createxml(xmldoc) from xml_tab
    ERROR:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00210: expected '<' instead of '<'
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 0
    ORA-06512: at line 1
    What could be the cause of the problem? Am I doing it in a correct way?
    -- Jitendra

    The main difference between CLOB and XMLType is that XMLType always contain a well formed XML document.
    So if CLOB doesn't complain , then XMLType does.

  • Conversion of a Base64EncodedXML CLOB to XMLTYPE

    I have an xml file which is base64 encoded and the base64 encoded file is stored as a clob. I want to do all the manipulation in PL/SQL and modify the clob column with one of xmltype
    Heres the steps I've got so far:
    i) convert the clob to a blob using dbms_lob.converttoclob
    ii) Since this is now in binary format I'm asusming that I don't need to cast to raw
    iii) decode the binary file using UTL_ENCODE.base64_decode
    iv) add an additional column  temp_xml as type xml_type
    v) update the temp_xml column with the values of the original column.
    update <tablename>
                   set temp_xml = xmltype(orig_clob_column) vi) At this stage I will see if I can read the xml in the new column and if all is successful, I will drop the orig_clob_column and rename temp_xml to orig_clob_column.
    If I've missed anything or anyone's got some gotchas for me, it would be appreciated.
    Message was edited by:
    Keith Jamieson
    Message was edited by:
    Keith Jamieson

    I am using Oracle 11g Windows and based on the example here:
    http://www.peakretrieval.com/plsql/Chapter16/Convert.sql
    create or replace PROCEDURE CONVERT_ME (
       v_blob_or_clob IN NUMBER,
       v_blob IN OUT BLOB,
       v_clob IN OUT CLOB,
       v_amount IN OUT NUMBER,
       v_blob_offset IN OUT NUMBER,
       v_clob_offset IN OUT NUMBER,
       v_lang_context IN OUT NUMBER,
       v_warning OUT NUMBER)
    AS
    BEGIN
       DBMS_LOB.OPEN(v_blob, DBMS_LOB.LOB_READWRITE);
       DBMS_LOB.OPEN(v_clob, DBMS_LOB.LOB_READWRITE);
       IF v_blob_or_clob = 0
       THEN
       DBMS_LOB.CONVERTTOBLOB(v_blob,
                              v_clob,
                              v_amount,
                              v_blob_offset,
                              v_clob_offset,
                              1,
                              v_lang_context,
                              v_warning);
       ELSE
       DBMS_LOB.CONVERTTOCLOB(v_clob,
                              v_blob,
                              v_amount,
                              v_clob_offset,
                              v_blob_offset,
                              1,
                              v_lang_context,
                              v_warning);
       END IF;
       DBMS_LOB.CLOSE(v_blob);
       DBMS_LOB.CLOSE(v_clob);
    END;When I run this sample code
    DECLARE
       v_clob_or_blob NUMBER;
       v_blob_locator BLOB;
       v_clob_locator CLOB;
       v_blob_offset NUMBER;
       v_clob_offset NUMBER;
       v_lang_context NUMBER := DBMS_LOB.DEFAULT_LANG_CTX;
       v_warning NUMBER;
       v_string_length NUMBER(10);
       v_source_locator BLOB;
       v_destination_locator BLOB;
       v_amount PLS_INTEGER;
       v_string CLOB;
    BEGIN
       -- CONVERT CLOB TO BLOB
       SELECT description
       INTO v_clob_locator
       FROM book_samples
       WHERE book_sample_id = 1
       FOR UPDATE;
       SELECT misc
       INTO v_blob_locator
       FROM book_samples
       WHERE book_sample_id = 1
       FOR UPDATE;
       v_string_length := DBMS_LOB.GETLENGTH(v_blob_locator);
       v_amount := DBMS_LOB.GETLENGTH(v_clob_locator);
       DBMS_OUTPUT.PUT_LINE('The initial length of the BLOB is: '||v_string_length);
            v_clob_or_blob := 0; -- Convert clob to blob
            v_clob_offset := 1;
            v_blob_offset := 1;
            CONVERT_ME(v_clob_or_blob,
                    v_blob_locator,
                    v_clob_locator,
                    v_amount,
                    v_blob_offset,
                    v_clob_offset,
                    v_lang_context,
                    v_warning);
       v_string_length := DBMS_LOB.GETLENGTH(v_blob_locator);
       DBMS_OUTPUT.PUT_LINE('The length of the BLOB post-conversion is: '||v_string_length);
       -- COPY BLOB FOR ONE ROW TO BLOB IN ANOTHER
       v_source_locator := v_blob_locator;
       SELECT misc
       INTO v_destination_locator
       FROM book_samples
       WHERE book_sample_id = 2
       FOR UPDATE;
       DBMS_LOB.COPY(v_destination_locator, v_source_locator, 32768, 1, 1);
       v_string_length := DBMS_LOB.GETLENGTH(v_destination_locator);
       DBMS_OUTPUT.PUT_LINE('The length of the BLOB post-copy is: '||v_string_length);
       -- COPY BLOB FOR RECORD 2 BACK TO A CLOB
       SELECT description
       INTO v_clob_locator
       FROM book_samples
       WHERE book_sample_id = 2
       FOR UPDATE;
       SELECT misc
       INTO v_blob_locator
       FROM book_samples
       WHERE book_sample_id = 2
       FOR UPDATE;
       v_string_length := DBMS_LOB.GETLENGTH(v_clob_locator);
       v_amount := DBMS_LOB.GETLENGTH(v_blob_locator);
       DBMS_OUTPUT.PUT_LINE('The initial length of the CLOB (record 2) is: '||v_string_length);
            v_clob_or_blob := 1; -- Convert blob to clob
            v_clob_offset := 1;
            v_blob_offset := 1;
            CONVERT_ME(v_clob_or_blob,
                    v_blob_locator,
                    v_clob_locator,
                    v_amount,
                    v_clob_offset,
                    v_blob_offset,
                    v_lang_context,
                    v_warning);
       v_string_length := DBMS_LOB.GETLENGTH(v_clob_locator);
       SELECT description
       INTO v_string
       FROM book_samples
       WHERE book_sample_id = 2;
       DBMS_OUTPUT.PUT_LINE('The length of the CLOB post-conversion is: '||v_string_length);
       DBMS_OUTPUT.PUT_LINE('     ');
       DBMS_OUTPUT.PUT_LINE('The converted CLOB');
       DBMS_OUTPUT.PUT_LINE('==================');
       DBMS_OUTPUT.PUT_LINE(SUBSTR(v_string,1,150));
       DBMS_OUTPUT.PUT_LINE(SUBSTR(v_string,151,300));
    EXCEPTION
       WHEN OTHERS
       THEN
          DBMS_OUTPUT.PUT_LINE('I''M BROKEN ... FIX ME!');
          DBMS_OUTPUT.PUT_LINE(SQLERRM);
    END;I get the following error:
    Length of blob before conversion
    The conver_me procedure is broken ...
    ORA-06502: PL/SQL: numeric or value error: invalid LOB locator specified: ORA-22275
    Length of blob after conversion

  • Which is better - BLOB, CLOB or XMLTYPE?

    Hi All,
    We have to store XML in one of the fields in our table.
    XML size is not fix but its not so huge that we shold go for external LOBs.
    I mean it will be alwas less than 4G.
    Our concern here is, does CLOB allocates exactly as much memory needed as much the data is present,(something like VARCHAR2).
    How is it in case of BLOB and XMLTYPE as well?
    Is there any Oracle documentation or way (code snippet) to verify this?
    Thanks in advnace.
    Avinash.

    You have asked if CLOB allocates space like VARCHAR2 - yes it does. Maybe this example will be better:
    SQL> TRUNCATE TABLE test_table;
    Tabela zosta│a obciŕta.
    SQL> insert into test_table values(LPAD('A', 100, 'A'));
    1 wiersz zosta│ utworzony.
    SQL> insert into test_table values(LPAD('A', 1000, 'A'));
    1 wiersz zosta│ utworzony.
    SQL> insert into test_table values(LPAD('A', 10000, 'A'));
    1 wiersz zosta│ utworzony.
    SQL> COMMIT;
    Zatwierdzanie zosta│o uko˝czone.
    SQL> SELECT LENGTH(col1) FROM test_table;
    LENGTH(COL1)
             100
            1000
            4000
    SQL>

  • Extract part of xml into CLOB or XMLType

    I need to extract part of XML into CLOB or some another type. But I don't need only extract data, by whole part od xml with elements. How could I do it in PL/SQL?
    For example from this xml:
    <bookstore>
    <book category="COOKING">
    <title lang="en">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
    </book>
    <book category="CHILDREN">
    <title lang="en">Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
    </book>
    </bookstore>
    I need to get:
    "<book category="COOKING">
    <title lang="en">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
    </book>"
    THX

    That's why I need to process every book alone - to know which authors belongs to single book.For that specific requirement, a single query would do.
    Assuming variable "v_xml_clob" holds the XML document :
    <bookstore>
      <name>nameOfBookstore</name>
      <address>1st Avenue 24, SF</address>
          <book category="COOKING">
            <title lang="en">Everyday Italian</title>
            <author>
              <name>Giada De Laurentiis</name>
              <birth>1956</birth>
            </author>
            <author>
              <name>xxx</name>
              <birth>1955</birth>
            </author>
            <year>2005</year>
            <price>30.00</price>
          </book>
          <book category="CHILDREN">
            <title lang="en">Harry Potter</title>
            <author>
              <name>Rowning</name>
              <birth>1977</birth>
            </author>
            <author>
              <name>xxx</name>
              <birth>1955</birth>
            </author>
            <year>2005</year>
            <price>29.99</price>
          </book>
    </bookstore>You can do :
    SELECT *
    FROM XMLTable(
    'for $i in distinct-values($d//book/author/name)
      where count($d//book/author[name=$i]) = 1
      return $i'
    passing xmltype(v_xml_clob) as "d"
    columns author_name varchar2(80) path '.'
    AUTHOR_NAME
    Rowning
    Giada De Laurentiis

  • How to insert data into clob or xmltype column

    when i am inserting to clob or xml type column i am getting error like ERROR at line 2:
    ORA-01704: string literal too long
    INSERT INTO po_clob_tab
    values(100,'<TXLife>
         <UserAuthRequest>
              <UserLoginName>UserId</UserLoginName>
         </UserAuthRequest>
         <TXLifeRequest>
              <TransRefGUID>0099962A-BFF3-4761-4058-F683398D79F7</TransRefGUID>
              <TransType tc="186">OLI_TRANS_CHGPAR</TransType>
              <TransExeDate>2008-05-29</TransExeDate>
              <TransExeTime>12:01:01</TransExeTime>
              <InquiryLevel tc="3">OLI_INQUIRY_OBJRELOBJ</InquiryLevel>
              <InquiryView>
                   <InquiryViewCode>CU186A</InquiryViewCode>
              </InquiryView>
              <ChangeSubType>
                   <ChangeTC tc="32">Update / Add Client Object Information</ChangeTC>
                   <!--TranContentCode tc = 1 (Add)
                                                           tc = 2 (Update)
                                                           tc = 3 (Delete)
                   -->
                   <TranContentCode tc="1">Add</TranContentCode>
              </ChangeSubType>
              <OLifE>
                   <SourceInfo>
                        <SourceInfoName>Client Profile</SourceInfoName>
                   </SourceInfo>
                   <Activity id="Act1" PartyID="Party1">
                        <ActivityStatus tc="2">In Progress</ActivityStatus>
                        <UserCode>123456</UserCode>
                        <Opened>2010-08-17</Opened>
                        <ActivityCode>CP10001</ActivityCode>
                        <Attachment>
                             <Description>LastScreenName</Description>
                             <AttachmentData>CP Create</AttachmentData>
                             <AttachmentType tc="2">OLI_ATTACH_COMMENT </AttachmentType>
                             <AttachmentLocation tc="1">OLI_INLINE </AttachmentLocation>
                        </Attachment>
                        <OLifEExtension VendorCode="05" ExtensionCode="Activity">
                             <ActivityExtension>
                                  <SubActivityCode>CP20001</SubActivityCode>
                             </ActivityExtension>
                        </OLifEExtension>
                   </Activity>
                   <Grouping id="Grouping1">
                        <Household>
                             <EstIncome>90000</EstIncome>
                        </Household>
                   </Grouping>
                   <Holding id="Holding1">
                        <HoldingTypeCode tc="2">Policy</HoldingTypeCode>
                        <Purpose tc="35">Accumulation</Purpose>
                        <Policy>
                             <ProductType tc="1009800001">AXA Network Non-Proprietary Variable Life Product</ProductType>
                             <ProductCode>Plus9</ProductCode>
                             <PlanName>Accumulator Plus 9.0</PlanName>
                             <Annuity>
                                  <QualPlanType tc="45">Qualified</QualPlanType>
                             </Annuity>
                             <ApplicationInfo>
                                  <ApplicationJurisdiction tc="35">New Jersey</ApplicationJurisdiction>
                                  <OLifEExtension VendorCode="05" ExtensionCode="ApplicationInfo">
                                       <ApplicationInfoExtension>
                                            <FinancialPlanIInd tc="0">False</FinancialPlanIInd>
                                            <AgentVerifiesOwnersID tc="1">True</AgentVerifiesOwnersID>
                                       </ApplicationInfoExtension>
                                  </OLifEExtension>
                             </ApplicationInfo>
                             <FinancialActivity>
                                  <FinActivityType tc="7">Initial Payment</FinActivityType>
                                  <FinActivityPct>10</FinActivityPct>
                                  <Payment>
                                       <SourceOfFundsTC tc="18">Gift</SourceOfFundsTC>
                                       <OLifEExtension VendorCode="05" ExtensionCode="Payment">
                                            <PaymentExtension>
                                                 <FundingDisclosureDetails>
                                                      <FundingDisclosureTC tc="1009800001">Cash</FundingDisclosureTC>
                                                 </FundingDisclosureDetails>
                                            </PaymentExtension>
                                       </OLifEExtension>
                                  </Payment>
                             </FinancialActivity>
                             <FinancialActivity>
                                  <FinActivityType tc="7">Initial Payment</FinActivityType>
                                  <FinActivityPct>10</FinActivityPct>
                                  <Payment>
                                       <SourceOfFundsTC tc="8">Personal Loan</SourceOfFundsTC>
                                       <OLifEExtension VendorCode="05" ExtensionCode="Payment">
                                            <PaymentExtension>
                                                 <FundingDisclosureDetails>
                                                      <FundingDisclosureTC tc="1009800002">Borrowing</FundingDisclosureTC>
                                                 </FundingDisclosureDetails>
                                            </PaymentExtension>
                                       </OLifEExtension>
                                  </Payment>
                             </FinancialActivity>
                             <FinancialActivity>
                                  <FinActivityType tc="7">Initial Payment</FinActivityType>
                                  <FinActivityPct>10</FinActivityPct>
                                  <Payment>
                                       <SourceOfFundsTC tc="10">Withdrawal</SourceOfFundsTC>
                                       <OLifEExtension VendorCode="05" ExtensionCode="Payment">
                                            <PaymentExtension>
                                                 <FundingDisclosureDetails>
                                                      <FundingDisclosureTC tc="1009800003">Policy Related</FundingDisclosureTC>
                                                 </FundingDisclosureDetails>
                                            </PaymentExtension>
                                       </OLifEExtension>
                                  </Payment>
                             </FinancialActivity>
                             <FinancialActivity>
                                  <FinActivityType tc="7">Initial Payment</FinActivityType>
                                  <FinActivityPct>10</FinActivityPct>
                                  <Payment>
                                       <OLifEExtension VendorCode="05" ExtensionCode="Payment">
                                            <PaymentExtension>
                                                 <FundingDisclosureDetails>
                                                      <FundingDisclosureTC tc="1009800005">Sale of 401(k) Mutual Fund Shares, Existing Pension Plan Assets, Stocks, Bonds, CD’s</FundingDisclosureTC>
                                                 </FundingDisclosureDetails>
                                            </PaymentExtension>
                                       </OLifEExtension>
                                  </Payment>
                             </FinancialActivity>
                             <FinancialActivity>
                                  <FinActivityType tc="7">Initial Payment</FinActivityType>
                                  <FinActivityPct>10</FinActivityPct>
                                  <Payment>
                                       <OLifEExtension VendorCode="05" ExtensionCode="Payment">
                                            <PaymentExtension>
                                                 <FundingDisclosureDetails>
                                                      <FundingDisclosureTC tc="1009800004">Sale of qualified or non-qualified Mutual Fund Shares</FundingDisclosureTC>
                                                 </FundingDisclosureDetails>
                                            </PaymentExtension>
                                       </OLifEExtension>
                                  </Payment>
                             </FinancialActivity>
                             <FinancialActivity>
                                  <FinActivityType tc="7">Initial Payment</FinActivityType>
                                  <FinActivityPct>20</FinActivityPct>
                                  <Payment>
                                       <OLifEExtension VendorCode="05" ExtensionCode="Payment">
                                            <PaymentExtension>
                                                 <FundingDisclosureDetails>
                                                      <FundingDisclosureTC tc="1009800006">Sale of Investment Advisory Assets</FundingDisclosureTC>
                                                 </FundingDisclosureDetails>
                                            </PaymentExtension>
                                       </OLifEExtension>
                                  </Payment>
                             </FinancialActivity>
                             <FinancialActivity>
                                  <FinActivityType tc="7">Initial Payment</FinActivityType>
                                  <FinActivityPct>20</FinActivityPct>
                                  <Payment>
                                       <SourceOfFundsTC tc="1009800008">Car</SourceOfFundsTC>
                                       <OLifEExtension VendorCode="05" ExtensionCode="Payment">
                                            <PaymentExtension>
                                                 <FundingDisclosureDetails>
                                                      <FundingDisclosureTC tc="2147483647">Other</FundingDisclosureTC>
                                                 </FundingDisclosureDetails>
                                            </PaymentExtension>
                                       </OLifEExtension>
                                  </Payment>
                             </FinancialActivity>
                        </Policy>
                   </Holding>
                   <Party id="Party1">
                        <PartyTypeCode tc="1">Person</PartyTypeCode>
                        <EstNetWorth>250000</EstNetWorth>
                        <LiquidNetWorthAmt>120000</LiquidNetWorthAmt>
                        <EstTotAssetsAmt>400000</EstTotAssetsAmt>
                        <Person>
                             <FirstName>John</FirstName>
                             <LastName>Doe</LastName>
                             <MarStat tc="1">Married</MarStat>
                             <Gender tc="1">Male</Gender>
                             <BirthDate>1965-05-07</BirthDate>
                             <EducationType tc="3">Associate Degree</EducationType>
                             <Citizenship tc="1">USA</Citizenship>
                             <NetIncomeAmt>70000</NetIncomeAmt>
                             <DriversLicenseNum>D123456789</DriversLicenseNum>
                             <DriversLicenseState tc="35">New Jersey</DriversLicenseState>
                             <ImmigrationStatus tc="8">Citizen</ImmigrationStatus>
                             <DriversLicenseExpDate>2012-05-25</DriversLicenseExpDate>
                             <OLifEExtension VendorCode="05" ExtensionCode="Person">
                                  <PersonExtension>
                                       <NoDriversLicenseInd tc="0">False</NoDriversLicenseInd>
                                  </PersonExtension>
                             </OLifEExtension>
                        </Person>
                        <Address>
                             <Line1>125 Finn Lane</Line1>
                             <City>North Brunswick</City>
                             <AddressStateTC tc="35">New Jersey</AddressStateTC>
                             <Zip>08902</Zip>
                        </Address>
                        <Phone>
                             <PhoneTypeCode tc="1">Home</PhoneTypeCode>
                             <DialNumber>732456789</DialNumber>
                        </Phone>
                        <Phone>
                             <PhoneTypeCode tc="2">Work</PhoneTypeCode>
                             <DialNumber>732987654</DialNumber>
                        </Phone>
                        <Attachment>
                             <Description>Comments</Description>
                             <AttachmentData>This is the comments entered for the client</AttachmentData>
                             <AttachmentType tc="2">OLI_ATTACH_COMMENT </AttachmentType>
                             <AttachmentLocation tc="1">OLI_INLINE </AttachmentLocation>
                        </Attachment>
                        <Attachment>
                             <AttachmentSysKey>1</AttachmentSysKey>
                             <Description>Additional Notes Important Considerations</Description>
                             <AttachmentData>This is the comments entered for the client</AttachmentData>
                             <AttachmentType tc="2">OLI_ATTACH_COMMENT </AttachmentType>
                             <AttachmentLocation tc="1">OLI_INLINE </AttachmentLocation>
                        </Attachment>
                        <Attachment>
                             <AttachmentSysKey>2</AttachmentSysKey>
                             <Description>Additional Notes Important Considerations</Description>
                             <AttachmentData>This is the comments entered for the client</AttachmentData>
                             <AttachmentType tc="2">OLI_ATTACH_COMMENT </AttachmentType>
                             <AttachmentLocation tc="1">OLI_INLINE </AttachmentLocation>
                        </Attachment>
                        <Client>
                             <NumRelations>1</NumRelations>
                             <EstTaxBracket>10</EstTaxBracket>
                             <BrokerDealerInd tc="1">True</BrokerDealerInd>
                             <EstIncomeAmt>90000</EstIncomeAmt>
                             <PrimaryInvObjective tc="8">Income and Growth</PrimaryInvObjective>
                             <InvHorizonRangeMin>5</InvHorizonRangeMin>
                             <OLifEExtension VendorCode="05" ExtensionCode="Client">
                                  <ClientExtension>
                                       <RiskToleranceCode tc="3">Moderate</RiskToleranceCode>
                                       <FINRAAffiliationName>John Doe</FINRAAffiliationName>
                                       <Rank>
                                            <RankCategory tc="1009800001">Financial Goal</RankCategory>
                                            <TotalRankCode>5</TotalRankCode>
                                            <RankCode PurposeID="1009800016">6</RankCode>
                                            <RankCode PurposeID="35">6</RankCode>
                                            <RankCode PurposeID="2">6</RankCode>
                                            <RankCode PurposeID="1009800013">6</RankCode>
                                            <RankCode PurposeID="1009800014">6</RankCode>
                                            <RankCode PurposeID="5">6</RankCode>
                                            <RankCode PurposeID="1009800015">6</RankCode>
                                       </Rank>
                                  </ClientExtension>
                             </OLifEExtension>
                        </Client>
                        <EMailAddress>
                             <EMailType tc="1">Business</EMailType>
                             <AddrLine>[email protected]</AddrLine>
                        </EMailAddress>
                        <Risk>
                             <HHFamilyInsurance>
                                  <HHFamilyInsuranceSysKey>1</HHFamilyInsuranceSysKey>
                                  <DeclinedInd tc="0">False</DeclinedInd>
                                  <LineOfBusiness tc="1">Life Insurance</LineOfBusiness>
                             </HHFamilyInsurance>
                             <HHFamilyInsurance>
                                  <HHFamilyInsuranceSysKey>2</HHFamilyInsuranceSysKey>
                                  <DeclinedInd tc="0">False</DeclinedInd>
                                  <LineOfBusiness tc="1">Life Insurance</LineOfBusiness>
                             </HHFamilyInsurance>
                             <HHFamilyInsurance>
                                  <HHFamilyInsuranceSysKey>1</HHFamilyInsuranceSysKey>
                                  <DeclinedInd tc="0">False</DeclinedInd>
                                  <LineOfBusiness tc="3">Disability Insurance</LineOfBusiness>
                             </HHFamilyInsurance>
                             <HHFamilyInsurance>
                                  <HHFamilyInsuranceSysKey>1</HHFamilyInsuranceSysKey>
                                  <DeclinedInd tc="0">False</DeclinedInd>
                                  <LineOfBusiness tc="5">LTC Insurance</LineOfBusiness>
                             </HHFamilyInsurance>
                             <FinancialExperience>
                                  <InvestmentType tc="7">CD</InvestmentType>
                                  <YearsOfInvestmentExperience>1</YearsOfInvestmentExperience>
                                  <OLifEExtension VendorCode="05" ExtensionCode="FinancialExperience">
                                       <FinancialExperienceExtension>
                                            <AssetValue>30000</AssetValue>
                                       </FinancialExperienceExtension>
                                  </OLifEExtension>
                             </FinancialExperience>
                             <FinancialExperience>
                                  <InvestmentType tc="3">Stock</InvestmentType>
                                  <YearsOfInvestmentExperience>1</YearsOfInvestmentExperience>
                                  <OLifEExtension VendorCode="05" ExtensionCode="FinancialExperience">
                                       <FinancialExperienceExtension>
                                            <AssetValue>5000</AssetValue>
                                       </FinancialExperienceExtension>
                                  </OLifEExtension>
                             </FinancialExperience>
                             <FinancialExperience>
                                  <InvestmentType tc="2">Bond</InvestmentType>
                                  <YearsOfInvestmentExperience>6</YearsOfInvestmentExperience>
                                  <OLifEExtension VendorCode="05" ExtensionCode="FinancialExperience">
                                       <FinancialExperienceExtension>
                                            <AssetValue>50000</AssetValue>
                                       </FinancialExperienceExtension>
                                  </OLifEExtension>
                             </FinancialExperience>
                             <FinancialExperience>
                                  <InvestmentType tc="15">Variable Annuities</InvestmentType>
                                  <YearsOfInvestmentExperience>4</YearsOfInvestmentExperience>
                                  <OLifEExtension VendorCode="05" ExtensionCode="FinancialExperience">
                                       <FinancialExperienceExtension>
                                            <AssetValue>50000</AssetValue>
                                       </FinancialExperienceExtension>
                                  </OLifEExtension>
                             </FinancialExperience>
                             <FinancialExperience>
                                  <InvestmentType tc="6">Mutual Funds</InvestmentType>
                                  <YearsOfInvestmentExperience>0</YearsOfInvestmentExperience>
                                  <OLifEExtension VendorCode="05" ExtensionCode="FinancialExperience">
                                       <FinancialExperienceExtension>
                                            <AssetValue>0</AssetValue>
                                       </FinancialExperienceExtension>
                                  </OLifEExtension>
                             </FinancialExperience>
                             <FinancialExperience>
                                  <InvestmentType tc="1009800001">Cash</InvestmentType>
                                  <YearsOfInvestmentExperience>20</YearsOfInvestmentExperience>
                                  <OLifEExtension VendorCode="05" ExtensionCode="FinancialExperience">
                                       <FinancialExperienceExtension>
                                            <AssetValue>100000</AssetValue>
                                       </FinancialExperienceExtension>
                                  </OLifEExtension>
                             </FinancialExperience>
                             <FinancialExperience>
                                  <InvestmentType tc="2147483647">Other</InvestmentType>
                                  <YearsOfInvestmentExperience>0</YearsOfInvestmentExperience>
                                  <OLifEExtension VendorCode="05" ExtensionCode="FinancialExperience">
                                       <FinancialExperienceExtension>
                                            <AssetValue>0</AssetValue>
                                       </FinancialExperienceExtension>
                                  </OLifEExtension>
                             </FinancialExperience>
                        </Risk>
                        <Employment EmployerPartyID="Party4">
                             <OccupClass tc="1009800001">Employed</OccupClass>
                             <Occupation>Solution Architect</Occupation>
                             <EmployerName>AXA</EmployerName>
                             <YearsAtEmployment>15</YearsAtEmployment>
                        </Employment>
                        <GovtIDInfo>
                             <GovtID>123456789</GovtID>
                             <GovtIDTC tc="17">Passport</GovtIDTC>
                             <GovtIDExpDate>2015-08-24</GovtIDExpDate>
                             <Nation tc="1">USA</Nation>
                             <Jurisdiction tc="35">New Jersey</Jurisdiction>
                        </GovtIDInfo>
                   </Party>
                   <Party id="Party2">
                        <PartyTypeCode tc="1">Person</PartyTypeCode>
                        <PartySysKey>ProfileID456</PartySysKey>
                        <Person>
                             <FirstName>Jacqueline</FirstName>
                             <LastName>Doe</LastName>
                             <MarStat tc="1">Married</MarStat>
                             <Gender tc="2">Female</Gender>
                             <BirthDate>1975-05-07</BirthDate>
                             <EducationType tc="3">Associate Degree</EducationType>
                             <Citizenship tc="1">USA</Citizenship>
                             <DriversLicenseNum>D987654321</DriversLicenseNum>
                             <DriversLicenseState tc="35">New Jersey</DriversLicenseState>
                             <ImmigrationStatus tc="8">Citizen</ImmigrationStatus>
                             <DriversLicenseExpDate>2012-05-25</DriversLicenseExpDate>
                             <OLifEExtension VendorCode="05" ExtensionCode="Person">
                                  <PersonExtension>
                                       <NoDriversLicenseInd tc="0">False</NoDriversLicenseInd>
                                  </PersonExtension>
                             </OLifEExtension>
                        </Person>
                        <Address>
                             <Line1>125 Finn Lane</Line1>
                             <City>North Brunswick</City>
                             <AddressStateTC tc="35">New Jersey</AddressStateTC>
                             <Zip>08902</Zip>
                        </Address>
                        <Phone>
                             <PhoneTypeCode tc="1">Home</PhoneTypeCode>
                             <DialNumber>732456789</DialNumber>
                        </Phone>
                        <Risk>
                             <HHFamilyInsurance>
                                  <HHFamilyInsuranceSysKey>1</HHFamilyInsuranceSysKey>
                                  <DeclinedInd tc="0">False</DeclinedInd>
                                  <LineOfBusiness tc="1">Life Insurance</LineOfBusiness>
                             </HHFamilyInsurance>
                        </Risk>
                        <Employment>
                             <OccupClass tc="4">Unemployed</OccupClass>
                        </Employment>
                        <GovtIDInfo>
                             <GovtID>987654321</GovtID>
                             <GovtIDTC tc="17">Passport</GovtIDTC>
                             <GovtIDExpDate>2015-08-24</GovtIDExpDate>
                             <Nation tc="1">USA</Nation>
                             <Jurisdiction tc="35">New Jersey</Jurisdiction>
                        </GovtIDInfo>
                   </Party>
                   <Party id="Party3">
                        <PartyTypeCode tc="1">Person</PartyTypeCode>
                        <Person>
                             <FirstName>Joe</FirstName>
                             <LastName>Doe</LastName>
                             <Age>15</Age>
                        </Person>
                   </Party>
                   <Party id="Party4">
                        <Person/>
                        <Address>
                             <Line1>425 Washington Blvd.</Line1>
                             <City>Jersey City</City>
                             <AddressStateTC tc="35">New Jersey</AddressStateTC>
                             <Zip>07302</Zip>
                        </Address>
                   </Party>
                   <Relation OriginatingObjectID="Grouping1" id="Relation1" RelatedObjectID="Party1">
                        <OriginatingObjectType tc="16">Grouping</OriginatingObjectType>
                        <RelatedObjectType tc="6">Party</RelatedObjectType>
                        <RelationRoleCode tc="30">Member</RelationRoleCode>
                   </Relation>
                   <Relation OriginatingObjectID="Grouping1" id="Relation2" RelatedObjectID="Party2">
                        <OriginatingObjectType tc="16">Grouping</OriginatingObjectType>
                        <RelatedObjectType tc="6">Party</RelatedObjectType>
                        <RelationRoleCode tc="30">Member</RelationRoleCode>
                   </Relation>
                   <Relation OriginatingObjectID="Party1" id="Relation3" RelatedObjectID="Party3">
                        <OriginatingObjectType tc="6">Party</OriginatingObjectType>
                        <RelatedObjectType tc="6">Party</RelatedObjectType>
                        <RelationRoleCode tc="40">Dependant</RelationRoleCode>
                   </Relation>
                   <Relation OriginatingObjectID="Holding1" id="Relation4" RelatedObjectID="Party1">
                        <OriginatingObjectType tc="4">Holding</OriginatingObjectType>
                        <RelatedObjectType tc="6">Party</RelatedObjectType>
                        <RelationRoleCode tc="8">Owner</RelationRoleCode>
                   </Relation>
                   <Relation OriginatingObjectID="Holding1" id="Relation5" RelatedObjectID="Party2">
                        <OriginatingObjectType tc="4">Holding</OriginatingObjectType>
                        <RelatedObjectType tc="6">Party</RelatedObjectType>
                        <RelationRoleCode tc="184">Joint Owner</RelationRoleCode>
                   </Relation>
                   <Relation OriginatingObjectID="Form1" id="Relation6" RelatedObjectID="Party1">
                        <OriginatingObjectType tc="101">FormInstance</OriginatingObjectType>
                        <RelatedObjectType tc="6">Party</RelatedObjectType>
                        <RelationRoleCode tc="107">Form For</RelationRoleCode>
                   </Relation>
                   <FormInstance id="Form1">
                        <FormResponse>
                             <ResponseText>No</ResponseText>
                             <QuestionType tc="1009800001">Is the Client/Owner with an interest in the account either: (A) a senior military, governmental, or political official in a non-U.S. country, or (B) closely associated with or an immediate family member of such official?</QuestionType>
                        </FormResponse>
                        <FormResponse>
                             <ResponseText>Yes</ResponseText>
                             <QuestionType tc="1009800005">I am familiar with the product(s) being sold and have determined proper suitability. For deferred variable annuity purchases only: I have reasonable grounds for believing that the recommendations for this customer to purchase/exchange an annuity is suitable on the basis of the facts disclosed by the customer as to his/her investments, insurance products and financial situation and needs.</QuestionType>
                        </FormResponse>
                   </FormInstance>
              </OLifE>
         </TXLifeRequest>
    </TXLife>');
    /

    It's a really bad idea to assemble XML using strings and string concatenation in SQL or PL/SQL. First there is a 4K limit in SQL, and 32K limit in PL/SQL, which means you end up constructing the XML in chunks, adding uneccessary complications. 2nd you cannot confirm the XML is valid or well formed using external tools.
    IMHO it makes much more sense to keep the XML content seperated from the SQL / PL/SQL code
    When the XML can be stored a File System accessable from the database, The files can be loaded into the database using mechansims like BFILE.
    In cases where the XML must be staged on a remote file system, the files can be loaded into the database using FTP or HTTP and in cases where this is not an option, SQLLDR.
    -Mark

  • XMLType and CLOB

    For full document retrieval and inserts is there a performance difference between declaring a XMLType or a simple CLOB database column type in table.
    Thanks in advance.

    I have a related question:
    Is there any difference between using the XMLTYPE constructor function and using XMLTYPE.CREATEXML to convert a temporary CLOB to XMLTYPE?
    I have the following in a PL/SQL function (simplified):
    FUNCTION get_geocode_xml( p_geocodes IN CLOB) RETURN XMLTYPE IS
      r_geocodes XMLTYPE;
    BEGIN
      r_geocodes := XMLTYPE.CREATEXML(p_geocodes);
      RETURN r_geocodes;
    END;Is this the same as using the constructor as in
    r_geocodes := XMLTYPE(p_geocodes);
    It seems to work either way, but I've only extensively tested the first method.

  • Trying to convert a CLOB to an XMLTYPE

    I'm trying to insert a xm ldocument stored in a CLOB into a XMLTYPE column registered to a schema.
    I'm trying so use the function below to convert the CLOB to an XMLTYPEbut i keep getting a ORA-06553 Error: wrong number or arguments. Am i using the xmltype constructor properly?
    create or replace function to_xmltype (clobcol CLOB)
    return xmltype as
    begin
    return xmltype(clobcol,'http://localhost:8080/source/schemas/poSource/xsd/mySchema.xsd');
    end;
    insert into xml_table (xmldata) values (select to_xmltype(ct.clob_data) from clob_table ct );
    Thanks for the help

    Looks fine to me except that you should omit the values clause:
    insert into xml_table (xmldata) select to_xmltype(ct.clob_data) from clob_table ct ;

  • Replace xml code when used as a xmltype converted from clob.

    I am still new at all this so I will try to make sense.
    I have the "sys_xmlgen" where it takes my clob_content which is a clob and converts it into the v_xml which is xmltype.
    ****code to show change of clob to xmltype.
    SELECT sys_xmlgen(clob_content) INTO v_xml FROM xmltest2 WHERE item_id = v_item_id;
    update xmltest2 set xml = v_xml where item_id = v_item_id;
    **end of code
    When you use sys_xmlgen it changes the xml into this example:
    <?xml version="1.0"?>
    <CLOB_CONTENT>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
    &lt;!DOCTYPE metadata SYSTEM &quot;csdgm2.dtd&quot;&gt;
    &lt;?xml-stylesheet href=&quot;FGDC_V2.xsl&quot; type=&quot;text/xsl&quot;?&gt;
    &lt;metadata&gt;
    &lt;idinfo&gt;
    </CLOB_CONTENT>
    I need to remove the <CLOB_CONTENT> tag and change some things such as the "&lt;" to a "<" and so on. But when I do a replace statement
    select replace(clob_content, '&lt;', '<') into v_xml from xmltest2;
    It says I can not do a clob into number.
    Just to make myself clear, the clob_content is clob and v_xml is xmltype. SOOO I think that is where my problem is. Does anyone know the syntax to replace the code in my xml so that it looks like the original clob xml??
    Any help would be appreciated.

    I am still new at all this so I will try to make sense.
    I have the "sys_xmlgen" where it takes my clob_content which is a clob and converts it into the v_xml which is xmltype.
    ****code to show change of clob to xmltype.
    SELECT sys_xmlgen(clob_content) INTO v_xml FROM xmltest2 WHERE item_id = v_item_id;
    update xmltest2 set xml = v_xml where item_id = v_item_id;
    **end of code
    When you use sys_xmlgen it changes the xml into this example:
    ?xml version="1.0"?>
    <CLOB_CONTENT>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
    &lt;!DOCTYPE metadata SYSTEM &quot;csdgm2.dtd&quot;&gt;
    &lt;?xml-stylesheet href=&quot;FGDC_V2.xsl&quot; type=&quot;text/xsl&quot;?&gt;
    &lt;metadata&gt;
    &lt;idinfo&gt;
    &lt;citation&gt;
    &lt;citeinfo&gt;</CLOB_CONTENT>
    I need to remove the <CLOB_CONTENT> tag and change some things such as the "<" to a "<" and so on. But when I do a replace statement
    select replace(clob_content, '<', '<') into v_xml from xmltest2;
    It says I can not do a clob into number.
    Just to make myself clear, the clob_content is clob and v_xml is xmltype. SOOO I think that is where my problem is. Does anyone know the syntax to replace the code in my xml so that it looks like the original clob xml??
    Any help would be appreciated.

  • How to convert XMLTYPE data into CLOB without using getclobval()

    Please tell me how to convert data which is stored in the table in XMLTYPE column to a CLOB.
    When i use getClobVal(), i get an error. So please tell me some other option except getClobVal()

    CREATE OR REPLACE PACKAGE BODY CONVERT_XML_TO_HTML AS
         FUNCTION GENERATE_HTML(TABLE_NAME VARCHAR2, FILE_NAME VARCHAR2, STYLESHEET_QUERY VARCHAR2, WHERE_CLAUSE VARCHAR2, ORDERBY_CLAUSE VARCHAR2) RETURN CLOB IS
         lHTMLOutput XMLType;
         lXSL CLOB;
              lXMLData XMLType;
              FILEID UTL_FILE.FILE_TYPE;
              HTML_RESULT CLOB;
              SQL_QUERY VARCHAR2(300);
              WHERE_QUERY VARCHAR2(200);
              fileDirectory VARCHAR2(100);
              slashPosition NUMBER;
              actual_fileName VARCHAR2(100);
              XML_HTML_REF_CUR_PT XML_HTML_REF_CUR;
              BEGIN
                   IF WHERE_CLAUSE IS NOT NULL AND ORDERBY_CLAUSE IS NOT NULL THEN
                   SQL_QUERY := 'SELECT * FROM ' || TABLE_NAME ||' WHERE ' || WHERE_CLAUSE || ' ORDER BY ' || ORDERBY_CLAUSE;
                        ELSE IF WHERE_CLAUSE IS NOT NULL AND ORDERBY_CLAUSE IS NULL THEN
                             SQL_QUERY := 'SELECT * FROM ' || TABLE_NAME || ' WHERE ' || WHERE_CLAUSE;
                             ELSE IF WHERE_CLAUSE IS NULL AND ORDERBY_CLAUSE IS NOT NULL THEN
                                  SQL_QUERY := 'SELECT * FROM ' || TABLE_NAME || ' ORDER BY ' || ORDERBY_CLAUSE;
                                  ELSE IF WHERE_CLAUSE IS NULL AND ORDERBY_CLAUSE IS NULL THEN
                                  SQL_QUERY := 'SELECT * FROM ' || TABLE_NAME;
                   END IF;
                        END IF;
                             END IF;
                                  END IF;
                   OPEN XML_HTML_REF_CUR_PT FOR SQL_QUERY;
              lXMLData := GENERATE_XML(XML_HTML_REF_CUR_PT);
                   --lXSL := GET_STYLESHEET(STYLESHEET_QUERY);
                                  if(lXMLData is not null) then
                                  dbms_output.put_line('lXMLData pass');
                                  else
                                            dbms_output.put_line('lXMLData fail');
                   end if;
                   lHTMLOutput := lXMLData.transform(XMLType(STYLESHEET_QUERY));
                   --INSERT INTO TEMP_CLOB_TAB2 VALUES(CLOB(lHTMLOutput));
                   if(lHTMLOutput is not null) then
                                  dbms_output.put_line('lHTMLOutput pass');
                                  else
                                            dbms_output.put_line('lHTMLOutput fail');
                   end if;
                   HTML_RESULT := lHTMLOutput.getclobVal();
                   if(HTML_RESULT is not null) then
                                  dbms_output.put_line('HTML_RESULT pass'||HTML_RESULT);
                                  else
                                            dbms_output.put_line('HTML_RESULT fail');
                   end if;
                   -- If the filename has been supplied ...
         IF FILE_NAME IS NOT NULL THEN
    -- locate the final '/' or '\' in the pathname ...
         slashPosition := INSTR(FILE_NAME, '/', -1 );
         IF slashPosition = 0 THEN
         slashPosition := INSTR(FILE_NAME,'\', -1 );
         END IF;
    -- separate the filename from the directory name ...
         fileDirectory := SUBSTR(FILE_NAME, 1,slashPosition - 1 );
         actual_fileName := SUBSTR(FILE_NAME, slashPosition + 1 );
                   END IF;
                        DBMS_OUTPUT.PUT_LINE(fileDirectory||' ' ||actual_fileName);
                   FILEID := UTL_FILE.FOPEN(fileDirectory,actual_fileName, 'W');
                   UTL_FILE.PUT_LINE(FILEID, '<title> hi </title>');
              UTL_FILE.PUT_LINE(FILEID, HTML_RESULT);
                   UTL_FILE.FCLOSE (FILEID);
    DBMS_OUTPUT.PUT_LINE('CLOB SIZE'||DBMS_LOB.GETLENGTH(HTML_RESULT));               
                   RETURN HTML_RESULT;
                   --RETURN lHTMLOutput;
              EXCEPTION
                        WHEN OTHERS
                             THEN DBMS_OUTPUT.PUT_LINE('ERROR!!!!!!!!!!!!');
              END GENERATE_HTML;
         FUNCTION GENERATE_XML(XML_HTML_REF_CUR_PT XML_HTML_REF_CUR) RETURN XMLType IS
              qryCtx DBMS_XMLGEN.ctxHandle;
              result CLOB;
              result1 xmltype;
              BEGIN
                   qryCtx := DBMS_XMLGEN.newContext(XML_HTML_REF_CUR_PT);
                   result := DBMS_XMLGEN.getXML(qryCtx);
                   --dbms_output.put_line(result);
                   result1 := xmltype(result);
                   INSERT INTO temp_clob VALUES(result);
                   if(result1 is not null) then
                                  dbms_output.put_line('pass');
                                  else
                                            dbms_output.put_line('fail');
                   end if;
                        return result1;
                        DBMS_XMLGEN.closeContext(qryCtx);
         END GENERATE_XML;     
    END CONVERT_XML_TO_HTML;
    This is the code which i am using to generate the XML and subsequently to generate the HTML output out of that using a XSL stylesheet.
    The error is Numeric or value error..

  • Unable to convert BLOB to XML using XMLTYPE

    Hello (XML) Experts
    I need your help with manipulating a BLOB column containing XML data - I am encountering the following error:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00200: could not convert from encoding UTF-8 to WINDOWS-1252
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 283
    I am on Windows 7 64 bit, Oracle 11.2.0.3 64 bit and database character set is WE8MSWIN1252, NLS_LANG is set to AMERICAN_AMERICA.AL32UTF8. The BLOB column contains the following XML data:
    <?xml version="1.0" encoding="utf-8"?>
    <Root CRC="-4065505">
      <Header Converted="0">
        <Version Type="String" Value="512" />
        <Revision Type="String" Value="29" />
        <SunSystemsVersion Type="String" Value="" />
        <Date Type="String" Value="20080724" />
        <Time Type="String" Value="165953" />
        <DAG Type="String" Value="" />
        <ChkID Type="String" Value="" />
        <FormType Type="String" Value="1" />
        <DB Type="String" Value="AllBusinessUnits" />
        <FuncID Type="String" Value="SOE" />
        <Status Type="String" Value="" />
        <FileType Type="String" Value="SFL" />
        <Descriptions>
          <Default Type="String" Value="Sales Order Entry" />
          <L01 Type="String" Value="Sales Order Entry" />
          <L33 Type="String" Value="Saisie commande client" />
          <L34 Type="String" Value="Entrada de órdenes de venta" />
          <L39 Type="String" Value="Inserimento ordine di vendita" />
          <L49 Type="String" Value="Aufträge erfassen" />
          <L55 Type="String" Value="Entrada de pedido de venda" />
          <L81 Type="String" Value="å?—注オーダー入力" />
          <L86 Type="String" Value="销售订å?•å½•å…¥" />
          <L87 Type="String" Value="銷售訂單錄入" />
        </Descriptions>
      </Header>
    <FormDesignerAppVer Type="String" Value="5.1" SFLOnly="1" />
    </Root>I am using the XMLTYPE constructor and passing in the BLOB column and the character set id of the XML data stored in the BLOB column in order to extract and update a node in the XML as follows:
    select xmltype(srce_form_detail,873) from SRCE_FORM where 873 above corresponds to the utf-8 encoding of the XML data in the BLOB column i.e. AL32UTF8, but this results in the above error.
    I have also tried converting the BLOB to a CLOB first as below where BLOB2CLOB is a function that converts the BLOB to a CLOB:
    select xmltype(BLOB2CLOB(srce_form_detail)).EXTRACT('/Root/Header/DB').getStringVal() XMLSrc  from SRCE_FORM;This results in the following error:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00210: expected '<' instead of '¿'
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 272
    ORA-06512: at line 1
    Looking at the XML in the BLOB I noticed that it contains a BOM(byte order mark) and this is causing the XML parsing to fail and I don't know how to deal with it and I don't want to simply SUBSTR it out.
    What I am trying to achieve is to extract the contents of the DB node in the XML and depending on its value I need to update the 'Value' part of that node. I am stuck at the point of extracting the contents of the DB node.
    I hope I have provided enough information and I would appreciate any suggestions on how best to resolve this - my XML knowledge is very limited so I would appreciate any help.
    Regards,
    Mohinder

    Hi Marc
    Thanks for your response.
    You are correct that the blob contains Japanese and Chinese characters but I was expecting that using the XMLTYPE constructor would convert the character set albeit with some data loss or then not display the Chinese and Japanese characters correctly.
    It seems to me that XMLTYPE is not handling/interpreting the BOM contained in the BLOB since even converting the BLOB to CLOB is resulting in an error. If I use SUBSTR and ignore the BOM to extract the XML from the BLOB then it works and as expected the Chinese and Japanese characters are not displayed correctly, they are displayed as '¿' corresponding to the lines beginning with L81, L86 & L87 , see below:
    select xmltype(SUBSTR(BLOB2CLOB(srce_form_detail),4)) from SRCE_FORM
    <?xml version="1.0" encoding="utf-8"?>
    <Root CRC="-4065505">
      <Header Converted="0">
        <Version Type="String" Value="512" />
        <Revision Type="String" Value="29" />
        <SunSystemsVersion Type="String" Value="" />
        <Date Type="String" Value="20080724" />
        <Time Type="String" Value="165953" />
        <DAG Type="String" Value="" />
        <ChkID Type="String" Value="" />
        <FormType Type="String" Value="1" />
        <DB Type="String" Value="AllBusinessUnits" />
        <FuncID Type="String" Value="SOE" />
        <Status Type="String" Value="" />
        <FileType Type="String" Value="SFL" />
        <Descriptions>
          <Default Type="String" Value="Sales Order Entry" />
          <L01 Type="String" Value="Sales Order Entry" />
          <L33 Type="String" Value="Saisie commande client" />
          <L34 Type="String" Value="Entrada de ¿¿rdenes de venta" />
          <L39 Type="String" Value="Inserimento ordine di vendita" />
          <L49 Type="String" Value="Auftr¿¿ge erfassen" />
          <L55 Type="String" Value="Entrada de pedido de venda" />
          <L81 Type="String" Value="¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿" />
          <L86 Type="String" Value="¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿" />
          <L87 Type="String" Value="¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿" />
        </Descriptions>
      </Header>Can you please let me know how I can extract the binary dump of the BLOB and post it on the forum as I don't know how to do this. Below is snippet of the hexadecimal dump, that includes the BOM. I can post the full hexadecimal dump if this can help you to reproduce the error ?
    EFBBBF3C3F786D6C2076657273696F6E3D22312E302220656E636F64696E673D227574662D38223F3E0D0A3C526F6F74204352433D222D34303635353035223E0D0A20203C48656164657220436F6E7665727465643D2230223E0D0A202020203C56657273696F6E20547970653D22537472696E67222056616C75653D2235313222202F3E0D0A202020203C5265766973696F6E20547970653D22537472696E67222056616C75653D22323922202F3E0D0A202020203C53756E53797374656D7356657273696F6E20547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C4461746520547970653D22537472696E67222056616C75653D22323030383037323422202F3E0D0A202020203C54696D6520547970653D22537472696E67222056616C75653D2231363539353322202F3E0D0A202020203C44414720547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C43686B494420547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C466F726D5479706520547970653D22537472696E67222056616C75653D223122202F3E0D0A202020203C444220547970653D22537472696E67222056616C75653D22416C6C427573696E657373556E69747322202F3E0D0A202020203C46756E63494420547970653D22537472696E67222056616C75653D22534F4522202F3E0D0A202020203C53746174757320547970653D22537472696E67222056616C75653D2222202F3E0D0A202020203C46696C655479706520547970653D22537472696E67222056616C75653D2253464C22202F3E0D0A202020203C4465736372697074696F6E733E0D0A2020202020203C44656661756C7420547970653D22537472696E67222056616C75653D2253616C6573204F7264657220456E74727922202F3E0D0A2020202020203C4C303120547970653D22537472696E67222056616C75653D2253616C6573204F7264657220456E74727922202F3E0D0A2020202020203C4C333320547970653D22537472696E67222056616C75653D2253616973696520636F6D6D616E646520636C69656E7422202F3E0D0A2020202020203C4C333420547970653D22537472696E67222056616C75653D22456E747261646120646520C3B37264656E65732064652076656E746122202F3E0D0A2020202020203C4C333920547970653D22537472696E67222056616C75653D22496E736572696D656E746F206F7264696E652064692076656E6469746122202F3E0D0A2020202020203C4C343920547970653D22537472696E67222056616C75653D224175667472C3A4676520657266617373656E22202F3E0D0A2020202020203C4C353520547970653D22537472696E67222056616C75653D22456E74726164612064652070656469646F2064652076656E646122202F3E0D0A2020202020203C4C383120547970653D22537472696E67222056616C75653D22E58F97E6B3A8E382AAE383BCE38380E383BCE585A5E58A9B22202F3E0D0A2020202020203C4C383620547970653D22537472696E67222056616C75653D22E99480E594AEE8AEA2E58D95E5BD95E585A522202F3E0D0A2020202020203C4C383720547970653D22537472696E67222056616C75653D22E98AB7E594AEE8A882E596AEE98C84E585A522202F3E0D0A202020203C2F4465736372697074696F6E733E0D0A20203C2F4865616465723E0D0A20203C466F726D3E0D0A202020203C4372656174696F6E4C616E6720547970653D22537472696E67222056616C75653D223031222053464C4F6E6C793D223122202F3E0D0A202020203C416374696F6E733E0D0A2020202020203C5065726D697373696F6E73202F3E0D0A202020203C2F416374696F6E733E0D0A202020203C48656C70202F3E0D0A202020203C466F6E743E0D0A2020202020203C446566466F6E7453697A6520547970653D22496E7465676572222056616C75653D2238222053464C4F6E6C793D223122202F3E0D0A2020202020203C466F6E743E0D0A20202020202020203C4C616E677561676520547970653D22537472696E67222056616C75653D2244656661756C7422202F3E0D0A20202020202020203C466F6E744E616D6520547970653D22537472696E67222056616C75653D224D532053616E7320536572696622202F3E0D0A2020202020203C2F466F6E743E0D0A2020202020203C466F6E743E0D0A20202020202020203C4C616E677561676520547970653D22537472696E67222056616C75653D22383122202F3E0D0A20202020202020203C466F6E744E616D6520547970653D22537472696E67222056616C75653D224D5320554920476F7468696322202F3E0D0A2020202020203C2F466F6E743E0D0A202020203C2F466F6E743E0D0A202020203C436F6E74726F6C733E0D0A2020202020203C436F6E74726F6C3E0D0A20202020202020203C436F6E74726F6C5479706520547970653D22496E746567657222204644496E743D2231222056616C75653D223122202F3E0D0A20202020202020203C446973706C61795479706520547970653D22537472696E6722204644496E743D2230222056616C75653D22466F726D2057696E646F77222053464C4F6E6C793D223122202F3E0D0A20202020202020203C43617074696F6E20547970653D22537472696E6722204644496E743D2230222056616C75653D2253597C3F7C55547C3F7C3F3F3F3F3F3F22202F3E0DThe XML I posted so far is actually truncated as the full XML is quite big but I showed the beginning of it as this is the section I believe that is not being handled properly. Furthermore I am able to write the BLOB out to a file successfully without any errors using DBMS_LOB & UTL_FILE.PUT_RAW and this seems to handle the BOM without any issues but what I really need to do is read a single node in the XML and update it directly preferably using XMLTYPE directly with the BLOB.
    I would welcome your suggestions on how best to read a single node and update it when the XML is contained in a BLOB.
    Regards,
    Mohinder

  • How to rename element (node) names in an XMLType column?

    I have a source table with a xml data stored in an XMLType column.
    The xml contains elements/nodes identified by numbers. I need to replace the numbers with the appropriate names.
    The plsql below does this, but has two issues:
    i. It selects the data into a clob and does a text replace on the elements in a loop. This works, but is super slow for 3500+ xml rows (about 500 node pairs per row).
    ii. Once the data has had the element numbers replaced with the names, it inserts the new xml (clob wrapped in xmltype function) into the table with the XMLType attribute.
    The problem with the latter action is that it is failing due to nls client vs server settings, or so it appears from what I could dig up. The actual error message:
    ORA-19202: Error occurred in XML processing
    LPX-00242: invalid use of ampersand ('&') character (use &amp;)
    Error at line 3
    There are come entities in the original xml like "&#61616;" (the degree symbol).
    My question is two-fold:
    a). Can I replace the element names without straying from the xmltype datatype? If so, how?
    b). If I cannot do "a.)", then what must I do ensure that the clob gets converted correctly to xmltype and inserted into the table?
    SQL> select <some rows> from nls_database_parameters ;
    PARAMETER VALUE
    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    NLS_CHARACTERSET WE8ISO8859P1
    NLS_NCHAR_CHARACTERSET AL16UTF16
    NLS_RDBMS_VERSION 10.2.0.1.0
    SQL> SELECT * FROM NLS_SESSION_PARAMETERS;
    PARAMETER VALUE
    NLS_LANGUAGE AMERICAN
    NLS_TERRITORY AMERICA
    ----code below-----
    (note, this is a stripped down version of the original, so there may be typos)
    declare
    l_xmlclob CLOB;
    l_newxml XMLType;
    v_record_uid NUMBER(20);
    CURSOR my_cur IS
    select a.elementname,b.tagname
    from t_elements a, t_tags b
    where (a.element_uid = b.element_uid)
    begin
    select br.xml_data.getClobVal() xml_data into l_xmlclob from t_elements;
    FOR my_rec IN my_cur LOOP
    l_xmlclob := replace(l_xmlclob,my_cur.elementname,my_cur.maptag_name);
    END LOOP;
    l_newxml := XMLType(l_xmlclob);
    insert into test_translated_xml (xml_data) values (l_newxml);
    end;
    (hopefully I haven't missed anything)
    Any tips or hints would be much appreciated.
    Thanks!

    Hello again,
    Take a look at html entity codes: http://www.w3schools.com/tags/ref_entities.asp.
    You can use this:
    insert into t values (xmltype('<test>'||dbms_xmlgen.convert('this is a test &')||'deg;</test>'));
    or
    insert into t values (xmltype('<test>'||dbms_xmlgen.convert('this is a test &')||'#176;</test>'));
    see this: &deg; (& deg;) or this: &#176; (& #176;)
    SQL*Plus will not display degree character. But this is valid enitity code, and when you generate HTML out of this, it should be displayed properly in web browser.
    HTML is in fact XML, that is validated by specific DTD (Document Type Definition).
    Paweł

  • Options to control display performance of CLOBs, etc. in Query Result view?

    Whenever I attempt to query a table that contains LOBs (e.g. a CLOB or XMLTYPE), the lack of performance pretty much makes the "Query Result" view (from F9) unusable. Any time I attempt to scroll the results, SQL developer apparently continues to query the database for the additional characters to populate the view.
    Resizing the columns containing the LOB to only a few characters almost solves the issue. Unfortunately, the size of the columns showing the LOBs apparently attempt to resize to the length of the LOB, making the column several pages long - and the same performance issue prevents resizing it smaller.
    Ideally, there would be some way to resize a column to a given or even a predefined and small size, without having to drag the resize handle the entire width of the desired resize amount. Alternatively, there could be a user preference to never set default column widths above a given number of pixels or characters. Another option would be a user preference to disable the in-line display of LOB contents, displaying only and requiring a click on the "..." (or pencil icon) button to open the "View Value" dialog. Ideally, all 3 of these options could be implemented.
    One crude work-around I'm using for now is to exclude the LOB columns from the results, requiring me to make secondary queries to see the LOB contents when necessary, and doesn't allow for scrolling through and viewing the LOB contents at all. Another work-around is to run the query as a script (F5) instead of a query (F9), and view the results in the "Script Output" view instead.
    I'm currently using SQL Developer 2.1.0.63, but experienced this same issue with all previous versions, including 1.5.5.
    Thanks!

    I agree.
    When I requested to auto-width the columns, I said to build in a maximum, but apparently they didn't.
    I suggest you log 2 feature requests on the SQL Developer Exchange; 1 for the maximum width, 1 for the CLOB contents/performance. Like this others can vote too and add weight for future implementation (I will).
    Have fun,
    K.

Maybe you are looking for

  • Multiple records in select options-Urgent help

    Hi all,    Iam using the following function module to get the set values. I need to pass multiple values in select options(ie) select options with no intervals. to the function module parameter Shortname. I have declared the variable which has to be

  • IOS 6.0.1 - Problems with certificate based authentication on wireless access point

    Hi all We are using iPad 2 as order terminals in our shops for about 5 months. Some of the iPads (the first who entered the field) started to cause problems now. These iPads are no longer able to keep long-term connection to the wireless access point

  • SRM Fiori  showing blank My SHopping Cart and error in Approve Shopping Cart

    Hi Experts We are implementing SAPUI5 MyShoppingCart Services embedded deployment with: -ehp 3 for sap srm 7.0 sp07 -netweaver 7.4 sp07 -gateway 2.0 we implemented three apps - Tracking SC, Approve and My SC we're getting good display in Tracking SC,

  • WRT610n access external ip from within LAN - NAT loopback

    Hi everybody, I've replaced my old ZyXEL P-320W with a WRT610n and lost one feature... I basically have a NAS assigned to IP 192.168.1.2, my router has IP 192.168.1.1 locally of course. Imagine I have IP X.X.X.X from the internet and that this IP is

  • Using jFreeCharts with JSP-Servlet Web App

    Can someone please help me to get started on using the jFreeCharts in mt JSP Servlet we app? So far I have this in my servlet but I do not know what to do from here. protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1) throws Serv