Query xml data from a CLOB datatye

All,
I read in an oracle white paper that is is possible to query XML data from CLOB datatype using oracle text index using operators HASPATH() and INPATH(). I am not able to find any example on how to do this. Can someone please post a simple example here.
Thank You very much!

SCOTT@10gXE> CREATE TABLE your_table (id NUMBER, xml_data CLOB)
  2  /
Table created.
SCOTT@10gXE> INSERT INTO your_table (id, xml_data)
  2  SELECT t.deptno,
  3           DBMS_XMLGEN.GETXML
  4             ('SELECT d.dname,
  5                   CURSOR (SELECT e.ename, e.job
  6                        FROM   emp e
  7                        WHERE  e.deptno = d.deptno) emp_data
  8            FROM   dept d
  9            WHERE  d.deptno = ' || t.deptno)
10  FROM   dept t
11  /
5 rows created.
SCOTT@10gXE> COMMIT
  2  /
Commit complete.
SCOTT@10gXE> begin
  2    ctx_ddl.create_section_group('xmlpathgroup', 'PATH_SECTION_GROUP');
  3  end;
  4  /
PL/SQL procedure successfully completed.
SCOTT@10gXE> CREATE INDEX myindex
  2  ON your_table(xml_data)
  3  INDEXTYPE IS ctxsys.context
  4  PARAMETERS ('datastore ctxsys.default_datastore
  5              filter ctxsys.null_filter
  6              section group xmlpathgroup'
  7            )
  8  /
Index created.
SCOTT@10gXE> SELECT * FROM your_table
  2  WHERE  CONTAINS (xml_data, 'PERSONNEL INPATH (//DNAME)') > 0
  3  /
        ID XML_DATA
        50 <?xml version="1.0"?>
           <ROWSET>
            <ROW>
             <DNAME>PERSONNEL</DNAME>
             <EMP_DATA>
             </EMP_DATA>
            </ROW>
           </ROWSET>
SCOTT@10gXE> SELECT * FROM your_table
  2  WHERE  CONTAINS (xml_data, 'HASPATH (//DNAME="PERSONNEL")') > 0
  3  /
        ID XML_DATA
        50 <?xml version="1.0"?>
           <ROWSET>
            <ROW>
             <DNAME>PERSONNEL</DNAME>
             <EMP_DATA>
             </EMP_DATA>
            </ROW>
           </ROWSET>
SCOTT@10gXE> SELECT * FROM your_table
  2  WHERE  CONTAINS (xml_data, 'CLARK INPATH (//ENAME)') > 0
  3  /
        ID XML_DATA
        10 <?xml version="1.0"?>
           <ROWSET>
            <ROW>
             <DNAME>ACCOUNTING</DNAME>
             <EMP_DATA>
              <EMP_DATA_ROW>
               <ENAME>CLARK</ENAME>
               <JOB>MANAGER</JOB>
              </EMP_DATA_ROW>
              <EMP_DATA_ROW>
               <ENAME>KING</ENAME>
               <JOB>PRESIDENT</JOB>
              </EMP_DATA_ROW>
              <EMP_DATA_ROW>
               <ENAME>MILLER</ENAME>
               <JOB>CLERK</JOB>
              </EMP_DATA_ROW>
             </EMP_DATA>
            </ROW>
           </ROWSET>
SCOTT@10gXE> SELECT * FROM your_table
  2  WHERE  CONTAINS (xml_data, 'HASPATH (//ENAME="CLARK")') > 0
  3  /
        ID XML_DATA
        10 <?xml version="1.0"?>
           <ROWSET>
            <ROW>
             <DNAME>ACCOUNTING</DNAME>
             <EMP_DATA>
              <EMP_DATA_ROW>
               <ENAME>CLARK</ENAME>
               <JOB>MANAGER</JOB>
              </EMP_DATA_ROW>
              <EMP_DATA_ROW>
               <ENAME>KING</ENAME>
               <JOB>PRESIDENT</JOB>
              </EMP_DATA_ROW>
              <EMP_DATA_ROW>
               <ENAME>MILLER</ENAME>
               <JOB>CLERK</JOB>
              </EMP_DATA_ROW>
             </EMP_DATA>
            </ROW>
           </ROWSET>
SCOTT@10gXE>

Similar Messages

  • Export XML data from a CLOB field using sql developer

    I have a table that contains a CLOB field, each record is a complete XML in itself. After running the select query i am exporting this data by right clicking on the answer set, while the export completes the data for each record gets truncated.
    When i chose to save the export in loader format i get the complete records but now there are n files created for n records exported.
    Is there a way i can get alll the records in a single file wirthout any truncation.
    Thanks in advance!

    You might try delimited format or csv, with no enclosures if desired.

  • How to query XML data stored in a CLOB column

    I don't know XMLDB, so I have a dumb question about querying XML data which is saved as CLOB in a table.
    I have a table (OLAP_AW_PRC), with a CLOB column - AW_XML_TMPL_VAL
    This column contains this xml data - [click here|http://www.nasar.net/aw.xml]
    Now I want to query the data using the xml tags - like returning the name of AW. This is where I am having trouble, how to query the data from AW_XML_TMPL_VAL clob column.
    The following query generates error:
    ORA-31011: XML parsing failed.
    ORA-19202: Error occurred in XML processing
    LPX-00229: input source is empty
    SELECT
    extractValue(value(x), '/AW/LongName') as "AWNAME"
    from
    OLAP_AW_PRC,
    table(xmlsequence(extract (xmltype(AW_XML_TMPL_VAL), '/AWXML/AWXML.content/Create/ActiveObject/AW'))) x
    where
    extractValue(value(x) , '/AW/Name') = 'OMCR4'
    - Nasar

    Mark,
    Thanks. This is exactly what I was looking for.
    After doing @Name in both places (SELECT and WHERE clause) it worked.
    Now I have one more question.
    There are multiple DIMENSION tags in my xml, and I want to see the NAME attribute values for all of those DIMENSIONs. The following query returns
    ORA-19025: EXTRACTVALUE returns value of only one node.
    Cause: Given XPath points to more than one node.
    Action: Rewrite the query so that exactly one node is returned.
    SELECT
    extractValue(value(x), '/AW/@Name') as "AW",
    extractValue(value(x), '/AW/Dimension/@Name') as "DIMENSIONS"
    from
    OLAP_AW_PRC,
    table(xmlsequence(extract (xmltype(AW_XML_TMPL_VAL), '/AWXML/AWXML.content/Create/ActiveObject/AW'))) x
    where
    extractValue(value(x) , '/AW/@Name') = 'OMCR4'

  • Update XML data stored in CLOB Column

    Hi All,
    i am new to Oracle and new to SQL
    i am trying to update XML data stored in CLOB cloumn,data is stored with the follwoing format
    <attrs><attr name="name"><string>Schade</string></attr></attrs>
    i am using the following query for updating the value
    UPDATE PRODUCT p SET ATTRIBUTES_nl_nl=UPDATEXML(XMLTYPE.createXML(ATTRIBUTES_nl_nl),'/attrs/attr[@name="name"]/string/text()','Schade').getClobVal() WHERE p.sku='000000000000040576_200911-5010057'
    this query is working fine but it changing the data to the following format
    <attrs><attr name="name">Schade</attr></attrs>
    some how it is ommiting the <string> tag from it, i am unable to figure it out whats the reason.
    any help in this regard will b e much appriciated
    Thanks in Advance
    -Umesh

    Hi,
    You should have created your own thread for this, and included database version.
    This works for me on 11.2.0.2 and 10.2.0.5 :
    SQL> create table t_org ( xml_clob clob );
    Table created
    SQL>
    SQL> insert into t_org
      2  values(
      3  '<Message>
      4  <Entity>
      5  <ASSIGNMENT>
      6  <OAVendorLocation> </OAVendorLocation>
      7  <Vendorid>1</Vendorid>
      8  </ASSIGNMENT>
      9  </Entity>
    10  </Message>'
    11  );
    1 row inserted
    SQL> commit;
    Commit complete
    SQL> select '*' ||
      2         extractvalue(xmltype(xml_clob),'/Message/Entity/ASSIGNMENT/OAVendorLocation')
      3         || '*' as result
      4  from t_org;
    RESULT
    SQL> update t_org set xml_clob =
      2  updatexml(xmltype(xml_clob),
      3  '/Message/Entity/ASSIGNMENT/OAVendorLocation/text()','LONDON').getClobVal()
      4  ;
    1 row updated
    SQL> select '*' ||
      2         extractvalue(xmltype(xml_clob),'/Message/Entity/ASSIGNMENT/OAVendorLocation')
      3         || '*' as result
      4  from t_org;
    RESULT
    *LONDON*
    Does the OAVendorLocation really have a whitespace value?
    If not then it's expected behaviour, you're trying to update a text() node that doesn't exist. In this case, the solution is to use appendChildXML to create the text() node, or update the whole element.
    Is it your real document? Do you actually have some namespaces?

  • Problem inserting and querying XML data with a recursive XML schema

    Hello,
    I'm facing a problem with querying XML data that is valid against a recursive XML Schema. I have got a table category that stores data as binary XML using Oracle 11g Rel 2 on Windows XP. The XML Schema is the following:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="bold_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="keyword_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
                   <xs:element name="plain_text" type="xs:string"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="emph_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="text_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="parlist_type">
              <xs:sequence>
                   <xs:element name="listitem" minOccurs="0" maxOccurs="unbounded" type="listitem_type"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="listitem_type">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="parlist" type="parlist_type"/>
                   <xs:element name="text" type="text_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:element name="category">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="name"/>
                        <xs:element name="description">
                                  <xs:complexType>
                                            <xs:choice>
                                                           <xs:element name="text" type="text_type"/>
                                                           <xs:element name="parlist" type="parlist_type"/>
                                            </xs:choice>
                                  </xs:complexType>
                        </xs:element>
                                                                </xs:sequence>
                                                                <xs:attribute name="id"/>
                                            </xs:complexType>
                        </xs:element>
    </xs:schema>I registered this schema and created the category table. Then I inserted a new row using the code below:
    insert into category_a values
    (XMlElement("category",
          xmlattributes('categoryAAA' as "id"),
          xmlforest ('ma categ' as "name"),
          (xmlelement("description", (xmlelement("text", 'find doors blest now whiles favours carriage tailor spacious senses defect threat ope willow please exeunt truest assembly <keyword> staring travels <bold> balthasar parts attach </bold> enshelter two <emph> inconsiderate ways preventions </emph> preventions clasps better affections comes perish </keyword> lucretia permit street full meddle yond general nature whipp <emph> lowness </emph> grievous pedro')))    
    The row is successfully inserted as witnessed by the results of row counting. However, I cannot extract data from the table. First, I tried using SqlPlus* which hangs up and quits after a while. I then tried to use SQL Developer, but haven't got any result. Here follow some examples of queries and their results in SQL Developer:
    Query 1
    select * from category
    Result : the whole row is returned
    Query 2
    select xmlquery('$p/category/description' passing object_value as "p" returning content) from category
    Result: "SYS.XMLTYPE"
    now I tried to fully respect the nested structure of description element in order to extract the text portion of <bold> using this query
    Query 3
    select  xmlquery('$p/category/description/text/keyword/bold/text()' passing object_value as "p" returning content) from  category_a
    Result: null
    and also tried to extract the text portion of element <text> using this query
    Query 4
    select  xmlquery('$p/category/description/text/text()' passing object_value as "p" returning content) from  category_a
    Result: "SYS.XMLTYPE".
    On the other hand, I noticed, from the result of query 1, that the opening tags of elements keyword and bold are encoded as the less than operator "&lt;". This explains why query 3 returns NULL. However, query 4 should display the text content of <text>, which is not the case.
    My questions are about
    1. How to properly insert the XML data while preserving the tags (especially the opening tag).
    2. How to display the data (the text portion of the main Element or of the nested elements).
    The problem about question 1 is that it is quite unfeasible to write a unique insert statement because the structure of <description> is recursive. In other words, if the structure of <description> was not recursive, it would be possible to embed the elements using the xmlelement function during the insertion.
    In fact, I need to insert the content of <description> from a source table (called category_a) into a target table (+category_b+) automatically .
    I filled category_a using the Saxloader utility from an flat XML file that I have generated from a benchmark. The content of <description> is different from one row to another but it is always valid with regards to the XML Schema. The data is properly inserted as witnessed by the "select * from category_a" instruction (500 row inserted). Besides, the opening tags of the nested elements under <description> are preserved (no "&lt;"). Then I wrote a PL/SQL procedure in which a cursor extracts the category id and category name into varchar2 variables and description into an XMLtype variable from category_a. When I try to insert the values into a category_b, I get the follwing error:
    LSX-00213: only 0 occurrences of particle "text", minimum is 1which tells that the <text> element is absent (actually it is present in the source table).
    So, my third question is why are not the tags recognized during the insertion?
    Can anyone help please?

    Hello,
    indded, I was using an old version of Sqlplus* (8.0.60.0.0) because I had a previous installation (oracle 10g XE). Instead, I used the Sqlplus* shipped with the 11g2database (version 11.2.0.1.0). All the queries that I wrote work fine and display the data correctly.
    I also used the XMLSERIALIZE function and can now display the description content in SQL Developer.
    Thank you very much.
    To answer your question Marco, I registered the XML Schema using the following code
    declare
      doc varchar2(4000) := '<?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="bold_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="keyword_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
                   <xs:element name="plain_text" type="xs:string"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="emph_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="text_type" mixed="true">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="bold" type="bold_type"/>
                   <xs:element name="keyword" type="keyword_type"/>
                   <xs:element name="emph" type="emph_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:complexType name="parlist_type">
              <xs:sequence>
                   <xs:element name="listitem" minOccurs="0" maxOccurs="unbounded" type="listitem_type"/>
              </xs:sequence>
         </xs:complexType>
         <xs:complexType name="listitem_type">
              <xs:choice minOccurs="0" maxOccurs="unbounded">
                   <xs:element name="parlist" type="parlist_type"/>
                   <xs:element name="text" type="text_type"/>
              </xs:choice>
         </xs:complexType>
         <xs:element name="category">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element name="name"/>
                        <xs:element name="description">
                                  <xs:complexType>
                                            <xs:choice>
                                                           <xs:element name="text" type="text_type"/>
                                                           <xs:element name="parlist" type="parlist_type"/>
                                            </xs:choice>
                                  </xs:complexType>
                        </xs:element>
                                                                </xs:sequence>
                                                                <xs:attribute name="id"/>
                                            </xs:complexType>
                        </xs:element>
    </xs:schema>';
    begin
      dbms_xmlschema.registerSchema('/xmldb/category_auction.xsd', doc,     LOCAL      => FALSE, 
            GENTYPES   => FALSE,  GENBEAN    => FALSE,   GENTABLES  => FALSE,
             FORCE      => FALSE,
             OPTIONS    => DBMS_XMLSCHEMA.REGISTER_BINARYXML,
             OWNER      => USER);
    end;then, I created the Category table as follows:
    CREATE TABLE category_a of XMLType XMLTYPE store AS BINARY XML
        XMLSCHEMA "xmldb/category_auction.xsd" ELEMENT "category";Now, there still remains a problem of how to insert the "description" content which I serialized as a CLOB data into another table as XML. To this purpose, I wrote a view over the Category_a table as follows:
    CREATE OR REPLACE FORCE VIEW "AUCTION_XWH"."CATEGORY_V" ("CATEGORY_ID", "CNAME", "DESCRIPTION") AS
      select category_v."CATEGORY_ID",category_v."CNAME",
      XMLSerialize(content ( xmlquery('$p/category/description/*' passing object_value as "p" returning content)) as clob) as "DESCRIPTION"
      from  auction.category_a p, 
    xmltable ('$a/category' passing p.Object_Value as "a"
    columns  category_id varchar2(15) path '@id',
              cname varchar2(20) path 'name') category_v;Then, I wrote a procedure to insert data into the Category_xwh table (the source and target tables are slightly different: the common elements are just copied wereas new elements are created in the target table). The code of the procedure is the following:
    create or replace PROCEDURE I_CATEGORY AS
    v_cname VARCHAR2(30);
    v_description clob ;
    v_category_id VARCHAR2(15);
    cursor mycursor is select category_id, cname, description from category_v;
    BEGIN
    open mycursor;
      loop
      /*retrieving the columns*/
      fetch mycursor into v_category_id, v_cname, v_description ;
      exit when mycursor%notfound;
      insert into category_xwh values
      (XMlElement("category",
          xmlattributes(v_category_id as "category_id"),
          xmlelement("Hierarchies", xmlelement("ObjHierarchy", xmlelement ("H_Cat"),
                                                               xmlelement ("Rollsup",
                                                                                  (xmlelement("all_categories",
                                                                                   xmlattributes('allcategories' as "all_category_id")))
        xmlforest (
                  v_cname as "cat_name",
                  v_description as "description")    
    end loop;
      commit;
      close mycursor;
    END I_CATEGORY;When I execute the procedure, I get the following error:
    LSX-00201: contents of "description" should be elements onlyso, I just wonder if this is because v_description is considered as plain text and not as XML text, even if its content is XML. Do I need to use a special function to cast the CLOB as XML?
    Thanks for your help.
    Doulkifli

  • How to read XML data stored in CLOB in Concurrent prog Output

    Hi All,
    I'm trying to Generate the XML Data as concurrent Program output. I have a PL/SQL package which generated the XML data by using SQL/XML functions. I'm storing the generated XML data in a CLOB variable. But when i try to read the data using fnd_file.put_line(fnd_file.OUTPUT,XML_Data) it doesn't display data more than 32767 bytes.
    Please help me out to understand what could be done to read the data in chunks. I have tried many logic's to print chunks of data but the output tags are either chopped off and errors out saying Tag not found.
    My logic is as below:
    v_handler:= DBMS_XMLGEN.newContext(v_xml_query);
    --Sets NULL handling options
    DBMS_XMLGen.SetNullHandling(v_handler, dbms_xmlgen.EMPTY_TAG ) ;
    --Set special character handling
    DBMS_XMLGEN.setConvertSpecialChars(v_handler, TRUE);
    -- Specified whether to use an XML attribute to indicate NULLness of particular entity in the XML document
    DBMS_XMLGen.useNullAttributeIndicator(v_handler,TRUE);
    -- set Checking invalid chars
    DBMS_XMLGEN.setCheckInvalidChars(v_handler, TRUE);
    -- get the xml data as required
    v_xml_data:= DBMS_XMLGEN.getXMLtype(v_handler);
    SELECT XMLROOT(v_xml_data.extract('/*'),VERSION '1.0').getClobVal() into v_new_xml_Data from dual;
    -- get the length of the xml generated
    v_clob_len := dbms_lob.getlength(v_new_xml_Data);
    FND_FILE.PUT_LINE(FND_FILE.LOG,'The Clob length is :'|| v_clob_len);
    -- logic to process string more than 32767 Processing by each character
    v_offset :=1;
    while (v_offset <= v_clob_len)
    LOOP
    v_char := dbms_lob.substr(v_new_xml_Data, 1, v_offset);
    IF (v_char = CHR(10))
    then
    fnd_file.new_line(fnd_file.output, 1);
    else
    fnd_file.put(fnd_file.output, v_char);
    end if;
    v_offset := v_offset + 1;
    END LOOP;
    FND_FILE.PUT_LINE(FND_FILE.LOG,'The offset is :'|| v_offset);
    FND_FILE.NEW_LINE(FND_FILE.OUTPUT, 1);
    THe above logic is for character by character which is a performance burden? Please let me know if there is any other work around for this

    Hi,
    Thanks for Replying. I have refered http://blog.oraclecontractors.com/?p=69 and then i added that piece of code. Basically, i'm trying to generate a report using XML publisher. To generate the XML data i'm writing a pl/sql package with SQl/XML functions. DBMS_XMLGEN would help me convert the XML Data as is. When the concurrent program runs this XML data will merge with RTF layout and generate required report. I'm able to generate the Report for data less then 32767 bytes. More than the limit i need to pass chunks of XML data to read as output. That's the reason i'm using fnd_file.output. But it reads only 32767 size at a time.
    WHen i use the given logic, it works perfectly fine, but it loops for each character, for example if you have 30,000 characters it loops the same, which is peformance burden.
    So i tried to write the logic of chunks but still i get the error that XML tag is not found or missing. I'm hoping this is very common issue, but after all my trails, i didn't find the right solution.
    the other logic i tried was :
    v_new_xml_data varchar2(32767)
    v_iterations := CEIL(v_clob_len/v_chunk_length); -- v_chunk_length is 32767 and v_clob_length is length of the XML data stored inthe clob variable
    For i in 0..v_iterations
    LOOP
    FND_FILE.put_line (fnd_file.log,'the loops v_pos :'||i||' and v_clob_length :'||v_clob_len);
    v_new_xml_data := DBMS_LOB.SUBSTR ( V_XML_DATA,v_chunk_length,(i*v_chunk_length)+1);
    FND_FILE.PUT_LINE (FND_FILE.OUTPUT,v_new_xml_data); -- read the output for every 32767 chunks
    FND_FILE.PUT_LINE(FND_FILE.LOG, 'Chunk length is :'||((i*v_chunk_length)+1));
    END LOOP;
    FND_FILE.put_line (fnd_file.log,'out of loop');
    FND_FILE.put_line (fnd_file.log,'length of new xml is '||v_clob_len);
    Please, let me know if you need Further clarifications on the same.

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

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

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

  • Using REGEXP_REPLACE to remove XML data from between XML tags

    Hello there,
    I am trying to use the REGEXP_REPLACE SQL function on a piece of XML, to remove the actual XML data from the elements. My end goal is to end up with a comma-delimited list of XML element names. As part of the first step, I just want to rip out all the actual data.
    I tested the following query, and it initially appeared to work:
    SELECT REGEXP_REPLACE('&gt;THIS IS A TEST&lt;',
                          '&gt;([[:alnum:]]\s|\S)*&lt;',
                          '&gt;&lt;' ) AS test_result
      FROM dual;Unfortunately, when I applied this to a full XML string, it didn't work. Here is the test query I used:
    SELECT REGEXP_REPLACE('&lt;ROW&gt;&lt;TEST_ELEMENT1&gt;123&lt;/TEST_ELEMENT1&gt;&lt;TEST_ELEMENT2&gt;THIS IS A TEST!&lt;/TEST_ELEMENT2&gt;&lt;/ROW&gt;',
                          '&gt;([[:alnum:]]\s|\S)*&lt;',
                          '&gt;&lt;') AS test_result
      FROM dual;I ended up with the following output:
    *&lt;ROW&gt;&lt;/ROW&gt;*
    What I was trying for was:
    *&lt;ROW&gt;&lt;TEST_ELEMENT1&gt;&lt;/TEST_ELEMENT1&gt;&lt;TEST_ELEMENT2&gt;&lt;/TEST_ELEMENT2&gt;&lt;/ROW&gt;*
    If you're reading this and you're a Posix RegExp Guru, please could you let me know exactly where I'm going wrong? RegExps are not my strong point, but I'd like to get better at them.

    jmcnaug2 wrote:
    Just out of interest, how would you go about writing the XQuery function so that it returns the actual XML Element values in comma-delimited form (This is Oracle Canonical XML, so has a very basic layout)? ;)Do you mean like this ?
    SQL> SELECT xmlquery(
      2    'for $i in $d/ROWSET/ROW
      3     return string-join($i/*, ",")'
      4    passing dbms_xmlgen.getXMLType('SELECT employee_id, last_name, first_name FROM employees WHERE rownum < 10') as "d"
      5    returning content
      6  ).getClobVal() as csv
      7  FROM dual;
    CSV
    100,King,Steven
    101,Kochhar,Neena
    102,De Haan,Lex
    103,Hunold,Alexander
    104,Ernst,Bruce
    105,Austin,David
    106,Pataballa,Valli
    107,Lorentz,Diana
    108,Greenberg,Nancy
    SQL>

  • Read/write xml data from/to adobe livecycle forms (pdf)

    Hello,
    I need some help reading xml data from pdfs created by Adobe LiveCycle and also writing xml data back to the form.
    The forms have been created using PROD LC 8.2 and in the future they will be created using PROD LC 9.5.
    I am using Visual Basic .NET to access the data programatically.
    Can anyone help me with some hints? A library, SDK? Any information would be very helpful.
    I am quite new with this Electronic Forms issue and I do not even know where to start.
    Thank you,
    Ionel

    Hi lonel,
    Do you want an online solution?
    I mean, it follows this workflow:
    1. The user will open the PDF by clicking a link, and a server-side program will generate the PDF and prepopulate it with data from some data sources, and render the PDF to the client (Browser),
    2. The user will fill the PDF.
    3. The user will click a Submit button and save the PDF and Data on the server.
    4. If the user wants to edit the Submitted Form, he will click a link to open the save PDF and possibly prepopulate some fields with data from other data sources, and complete the cycle of filling and saved the PDF and Data on the server.
    5. While the user is filling the PDF (inside a Browser), there might be a need to perform some lookup on the server, and update the form parts accordingly as a result of the lookup process.
    For 1-4 above, I have developed a complete base library using ASP.NET which helps you to perform the above.
    You can goto my Google Workspace and you will find a bunch of documents, sample PDFs, collections and VB Classes. To best view them, login using some Google Account.
    For point 4 above, one way to perform this effect, is to regenerate the required XML Data (which has the saved data before and the new lookup data), remerge the entire XML result with and empty PDF Form, and render the XFA (PDF Form) back to the client. But, if the PDF has one or more signatures, it will not work. So, in this case, you can update the Form Fields of a Saved PDF Form with new Data from the server, but the net effect is that you will have to loose all the signatures that were added on the PDF before.
    For 5 (above) there are 3 methods:
    1. Using a Web Service as a Data Connection. This is very easy if you have a traditional Web Service. I have used this method several times and will use it again if the need be. But, there is a problem. If the result of the Web Service is an Array of some Data, and you want to remerge the XFA to get the required effect after executing the web service ... and ... if there are some Drop-Down-List (DDL) fields, the bindings of the DDL Items of those fields will be lost. But, you can rebuild them (on enter event of the DDL Field)  if you have saved them in the embedded XML Data.
    2. You can update few (not many) fields while the PDF is opened (under the Browser via IFRAME) by passing the new field values using the URL Query String method. I have not done this, but I like this method, and I think it is cool. You need to write a server side code to ensure the the new filed values are passed back to the client using the correct URL with the Query String, and you need to write some javascript code inside the PDF to parse the URL and get the new field values and update them accordingly. See this as an example:
    http://www.halnesbitt.com/pages/pdfqs.php
    3. This method is very advanced and uses message communication ques between the Browser and the PDF (which is opened inside IFRAME element) using HostContainer object. This method will enable 2-way communication between the Browser and the PDF on the client side using javascript. I'd love to use this method one day. See example here:
    http://www.windjack.com/WindJack/Browser2PDF/brwsr2acroJS.htm
    I hope this will be of help to you.
    Tarek.

  • How to generate XML data from Lotus Notes to migrate to SharePoint by passing XML to SharePoint.?

    How to generate XML data from Lotus Notes to migrate to SharePoint by passing XML to SharePoint.?
    Ramesh S

    You could use XMLQuery to return the data from your tables as XML, that would give you a CLOB.
    An example using the SCOTT schema might be like this:
    SELECT XMLQuery(
             'for $i in ora:view("DEPT")/ROW
              return <Department dname="{$i/DNAME}">
                     <Employee>
                       {for $j in ora:view("EMP")/ROW
                        where $j/DEPTNO eq $i/DEPTNO
                        return ($j/ENAME, $j/JOB, $j/SAL)}
                     </Employee>
                     </Department>'
             RETURNING CONTENT) FROM DUAL;In the docs you can find more information about its use:
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10492/xdb_xquery.htm

  • Reading XML Data from ABAP Program?

    Hi,
    How do I read XML Data from an ABAP Program? For example if I have the below basic XML Code-
    <xml>
    <Name> Thiru </Name>
    <Age> 24 </Age>
    <City> chennai </Chennai>
    </xml>
    How do i read the data within the Name,Age, and City tags into variables in the ABAP Program?
    Regards,
    Thiru

    if you decide to do in XSLT, I have a sample list here:
    XML file like this:
    <?xml version="1.0" encoding="UTF-16"?>
    <F>
    <P1>
    <t_1>value1</t_1>
    <t_2>testvalue</t_2>
    </P1>
    <P2>
    </P2>
    </F>
    XSLT file like this:
    <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sapxsl="http://www.sap.com/sapxsl" version="1.0">
    <xsl:strip-space elements="*"/>
    <xsl:template match="F">
    <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
    <asx:values>
    <<b>DOCUMENT</b>>
    <xsl:apply-templates/>
    </<b>DOCUMENT</b>>
    </asx:values>
    </asx:abap>
    </xsl:template>
    <xsl:template match="P1">
    <ENTRY>
    <<b>T_1</b>><xsl:value-of select="t_1"/></T_1>
    <<b>T_2</b>><xsl:value-of select="t_2"/></T_2>
    </ENTRY>
    </xsl:template>
    </xsl:transform>
    ABAP program like this:
    DATA: BEGIN OF wa_upload,
    text(255) TYPE c,
    END OF wa_upload,
    itab_upload LIKE TABLE OF wa_upload,
    BEGIN OF wa_document,
    t_1 TYPE string,
    t_2 TYPE string,
    END OF wa_document,
    itab_document LIKE TABLE OF wa_document.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = 'XXXXX'
    filetype = 'ASC'
    TABLES
    data_tab = itab_upload.
    CALL TRANSFORMATION zrappel_xml_test
    SOURCE XML itab_upload
    RESULT <b>document</b> = itab_document.
    You should pay attention to the bold words.
    hope it will be helpful
    thanks

  • Parsing an xml data from a buffer

    I have an XML file loaded into a string buffer in java. I would like to know if I can parser XMl data from that buffer using the SAX parser. I do not want to load the xml using the parser, I would like to load the buffer instead.
    Thanks in advance,
    Sudheer.

    StreamSource ss = new StreamSource(new StringReader(myString));
    transformer.transform(ss, new StreamResult(outputFile));

  • How can I get xml data from KM?

    Hi guys,
    how can i get a xml data from KM?
    I saved an xml document in KM, and I want to read its content. How can I get this document?
    Using
    DocResource = (IResource) resFactory.getResource(RID.getRID("Document/ Path"),resContext)?
    I want to know which kinds of API of KM are responsible for this.
    Thanks in advance
    Regards,
    Liying

    Hi Liying
    use this code.
    try {
                   IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
                   IUser sapUser = wdClientUser.getSAPUser();
                   com.sapportals.portal.security.usermanagement.IUser ep5User =
                        WPUMFactory.getUserFactory().getEP5User(sapUser);
                   IResourceContext resourseContext = new ResourceContext(ep5User);
                   IResourceFactory resourseFactory = ResourceFactory.getInstance();
                   RID pathRID =
                        RID.getRID(
                             "/documents/"(Path to folder where ur file is"");
                   ICollection collection =
                        (ICollection) resourseFactory.getResource(
                             pathRID,
                             resourseContext);
                   IResourceList resourceList = collection.getChildren();
                   IResourceListIterator resourceListIterator =
                        resourceList.listIterator();
    while (resourceListIterator.hasNext()) {
                        com.sapportals.wcm.repository.IResource resource =
                             resourceListIterator.next();
    try {
                             /*File from KM Reading*/
                             InputStream in = resource.getUnfilteredContent().getInputStream();
                             ByteArrayOutputStream out = new ByteArrayOutputStream();
                             byte[] buffer = new byte[4096];
                             int bytesread = 0;
                             while ((bytesread = in.read(buffer)) != -1) {
                                  out.write(buffer, 0, bytesread);
                             String dataToBeConvertedToXML = out.toString();
    catch(Exception e){}
    catch(Exception e){}
    Award points if found usefull.
    I suppose you have used KM sharing reference in ur application
    Regards
    BP

  • Group xml data from different sql queries in data template

    Hello,
    I need to do a mailing program with bursting that sends differents alerts in one mail.
    For example i can have alerts for late orders, alerts for shipping not confirmed, so really different address (I dont want to use union). I have done three sql statement in data template , it gives the following ouput.
    <GA_EMAIL>[email protected]</GA_EMAIL>
    <G_ALERTS_1>
    <ALERT>
    </ALERT>
    <ALERT>
    </ALERT>
    </G_ALERTS_1>
    </GA_EMAIL>
    <GA_EMAIL>[email protected]</GA_EMAIL>
    <G_ALERTS_1>
    <ALERT>
    </ALERT>
    </G_ALERTS_1>
    </GA_EMAIL>
    <GA_EMAIL>[email protected]</GA_EMAIL>
    <G_ALERTS_2>
    </G_ALERTS_2>
    </GA_EMAIL>
    I woud like the bursting or data template to group alerts when email is the same, because here it sends an email for each different alert.
    Ideal output would be:
    <GA_EMAIL>[email protected]</GA_EMAIL>
    <G_ALERTS_1>
    <ALERT>
    </ALERT>
    <ALERT>
    </ALERT>
    </G_ALERTS_1>
    <G_ALERTS_2>
    </G_ALERTS_2>
    </GA_EMAIL>
    But I don't know how to group different sql statements on a common field (email)
    Any ideas ?
    Thanks

    the for-each group works well in a rtf template, but the rtf template is only applied after the bursting (in order I get first data template (instead of a report) -> bursting -> rtf template)
    I want to be able to group xml data from the data template, so I can do bursting (by email ) but only once per mail.

  • Extracting SAP Query,Infoset  Data from VB Application

    Hi,
    I need to get all SAP Queries,Infosets and SAP Query Group data from a VB application.
    I have found a Remote Enabled Function called    IQAPI_READ_QUERY_CATALOG.
    But when I call the Function from a VB application ,the call is not successful and even I am not getting any exception.
    The call is getting false with null exception .
    Can anyone please guide me.
    Or is there any other function module /procedure / table to extract SAP Query ,Infoset,SAP Query Group data??
    Thanks in Advance.

    http://stackoverflow.com/questions/3765373/how-do-i-do-a-select-distinct-using-a-sap-infoset-query

Maybe you are looking for