Error updating a CLOB XML fragment

Hi,
I have an xml schema that contains an element of type xs:anyType that has been mapped to Oracle as CLOB.
Now I have the needs to update this value but I was not able to do it.
The code that does the update is the following:
public void updateXML(String sqlCmd, String XMLString) throws Exception
DataSource ds = null;
Connection conn = null;
OraclePreparedStatement stmt = null;
oracle.sql.CLOB tempCLOB = null;
Writer tempCLOBWriter= null;
try
//Get Data Source
ds = (DataSource) new InitialContext().lookup(xmlDS);
// Get Connection
conn = ds.getConnection();
// Prepare statement with requested insert, update or delete statement
stmt = (OraclePreparedStatement) ((OracleConnection) conn).prepareStatement(sqlCmd);
// Build CLOB containing XML if required
if (XMLString != null)
tempCLOB = oracle.sql.CLOB.createTemporary
( ((WLConnection)conn).getVendorConnection(),
true,
CLOB.DURATION_SESSION);
try {
tempCLOB.open(CLOB.MODE_READWRITE);
tempCLOBWriter = tempCLOB.getCharacterOutputStream();
tempCLOBWriter.write(XMLString);
tempCLOBWriter.flush();
} finally {
if (tempCLOBWriter != null)
tempCLOBWriter.close();
//Set parameter on Prepared Statement
stmt.setCLOB(1,tempCLOB);
// Execute command
stmt.executeUpdate();
// Clean up CLOB data if required
if (XMLString != null)
tempCLOB.freeTemporary();
// Return connection to the pool
conn.close();
catch ( Exception e)
if (conn != null)
conn.close();
throw e;
IF the sqlCmd param contains:
update XML_OPERAZIONE_LOG t
set value(t) = updateXML(value(t),
'/operazione.log/Operazione',XMLTYPE(?))
where existsNode(value(t),
'/operazione.log/Journal [NumeroElettronico="99900000"]') = 1
I get the error ORA-17410 "No More Data to read from socket"
If the sqlCmd contains:
insert into XML_OPERAZIONE_LOG values( XMLType(?))
I have no problems.
Any Idea ?
Oracle 9.2.0.2.0, latest classes12.zip BEW Web Logic 8.1

Upgrade to 9.2.0.5.0 since 9.2.0.2.0 is not supported for XMLType. Also try OCI rather than thin dirver.

Similar Messages

  • Migrating V9 to V10: Update XML Fragment CLOB does not work anymore

    I have an XML Schema that contains an element, named Operazione, mapped to a CLOB.
    I just migrate to Oracle 10.1.0.2.0 from version 9.2.0.2.0 and the code I developed does not work anymore.
    To get a CLOB on v 9.2.0.2.0 I issued the following statement:
    select extractValue(value(p),'/operazione.log/Operazione') from XMT_OPERAZIONE_LOG p
    where existsNode(value(p),'/operazione.log/Journal[NumeroElettronico=1234567890]') = 1
    To make it working on V10 I have to change it as follow:
    select extract(value(p),'/operazione.log/Operazione').getClobVal() from XMT_OPERAZIONE_LOG p
    where existsNode(value(p),'/operazione.log/Journal[NumeroElettronico=1234567890]') = 1
    So using extract intead of extractValue and adding getClobVal() I was able to read the CLOB.
    The problem that I was not able to solve is related to CLOB update. In V9 just adding the “for update” clause I was able to change the CLOB value on DB.
    In V10 if I run the V9 statement I get the error:
    ORA-03113: end-of-file on communication channel
    If I use the statement modified for V10, adding the “for update” clause, I get the CLOB and I can change the CLOB value but nothing goes on the DB. Probably I am working on a copy of the DB CLOB.
    If I remove the getClobVal() I get an OPAQUE type that I can use on a XMLType but, still, nothing is stored on DB.
    Any suggestion ?
    I tried with both OCI and Thin Client

    Can anybody help me ?
    Is it better to use different strategies ( eg. Stored Procedure, DBMS_XMLSTORE etc, etc. ) ?
    Any experience updatating XML Fragment CLOB on Oracle V10 ?

  • ORA-30936 error updating a SQLType="CLOB" field

    PROBLEM:
    I'm using Oracle 9.2.0.4 on Solaris 64bit.
    My table is:
    create table cd3_tab(id number primary key, cd xmltype)
    xmltype column cd
    xmlschema "cd3.xsd" element "CDS"
    I have inserted one xml file into cd field.The id has value 2.
    Below you can find the schema.
    Using:
    update cd3_tab cd=updateXML(cd,'/CDS/CD[1]/Description/text()','xxx')
    where id =2
    i get: ORA-30936 Maximum Number(1) of 'Description' XML node elements exceeded.
    As you can see in the schema the Description filed is defined with the xdb:SQLType="CLOB" directive because it can be longer than 4k.
    If i do:
    update cd3_tab cd=updateXML(cd,'/CDS/CD[1]/Title/text()','xxx')
    where id =2
    i got the same error and THIS IS BIZARRE always on the 'Description' node even if my update now in on the 'Title' filed.
    OTHER TEST
    ==========
    Also the same error occurs when i select the Description node:
    select extract(cd,'/CDS/CD[1]/Description/text()') from cd3_tab where id=2;
    if i use : select extract(cd,'/CDS/CD[1]/Description') from cd3_tab where id=2;
    i got no error.
    SCHEMA
    ======
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb">
    <xs:element name="CDS">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="CD" minOccurs="1" maxOccurs="unbounded" xdb:SQLInline="false"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="CD">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="Title" type="xs:string"/>
    <xs:element name="Artist" type="xs:string"/>
    <xs:element name="Website" type="xs:anyURI"/>
    <xs:element name="Description" xdb:SQLName="DESCRIZIONE_T" xdb:SQLType="CLOB"/>
    <xs:element name="Songs">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="Song" maxOccurs="unbounded">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="Title" type="xs:string"/>
    <xs:element name="PlayingTime" type="xs:string"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>

    Upgrade to 9.2.0.5.0 since 9.2.0.2.0 is not supported for XMLType. Also try OCI rather than thin dirver.

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

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

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

  • Want to retrieve multiple XML fragments in CLOBs in a *single query*

    Hi,
    I am trying to retrieve some well formed XML fragments stored as CLOBs from an 8i DB. For a single fragment at a time this is not a problem using <xsql:include-xml>. However, I am trying to retrieve multiple well formed fragments in a single query, "stacked" like so...
    <xsql:include-xml>
    <![CDATA[
    select theXMLFrag from tclob1 where id = 'open'
    union all
    select theXMLFrag from tclob2 --returns multiple rows
    union all
    select theXMLFrag from tclob3 --some more rows
    union all
    select theXMLFrag from tclob1 where id = 'close'
    ]]>
    </xsql:include-xml>
    What I am really after are the contents from the middle two selects. (The 'open' and 'close' bit was just a cheap attempt to ensure that the included XML is well formed.) Though it is not shown in my example, the problem is that the number and source of the CLOB fragments is not known until run time, and I wanted to use a dynamic query to assemble the needed CLOBS...
    I have since learned that <xsql:include-xml> returns the first column of the first row of the query result as parsed XML, either from a CLOB or a VARCHAR containing well-formed XML. So my attempt is no good... all but the first row are ignored.
    Does anyone have any suggestions for a way to do this using the existing xsql tag library? Or will I need to create my own <xsql:action>?
    Thanks,
    Bob Nugent

    Hi,
    Let me correct if i am right:
    - Central Contract -> new concept of SRM 7.0. 1 contract which is visible and usable from ECC and SRM as well. (not available in SRM 5.0 - agree)
    - GOA -> it exist in SRM 5.0 for sure! (we are currenlty using it for ECC procurement).
    The solution what you are mentioned is good...but as you said only for SRM 70...we are in SRM 5.0 and we need solution for here. Do you have any idea?
    Currently i am thinking about a new solution based on "standard" functionalities: if a GOA need to be created for mulitple company, it has to be populated in Header distribution (all company will have the same contract header). It item detail all the required information need to be poupulate in SRM (i.e.: item 1 for p.org1/comp.cod1; item 2 for p.org2/comp.cod2).
    When this is done, the BADI need to check the informatoin in SRM GOA and create contract according to that -> in this case 1GOA is created, but the 2 items for totally different p.org/comp.code, the BADI needs to create 2 different contract in ECC (i would like to avoid using reference purchasing organization in ECC!
    Thanks in advance!
    Best Regards,
    Attila

  • How To Store XML Fragments Using Functions Such As XMLElement

    Hi
    Not sure what I am missing. I wish to store XML fragments in variables so can pass around and concatenate with other fragments to make final XML document. Even before attempting to concatenate XML fragments, I am struggling to store any XML fragment in a variable. I am trying to use simple functions such as XMLElement to generate XML so can store in variable. I have seen many examples of XMLElement in SQL select statement. Can XMLElement be used in plsql? XMLElement says it returns value of type XMLType. Functions such as XMLElement make generating XML easier than creating all tags manually.
    Below is simple example that demonstrates what I would like to do. I would like to be able to pass the XML fragment as either XMLType or clob. I receive error saying PLS-00201: identifier 'XMLELEMENT' must be declared
    declare
    vTheData XMLType;
    vTheDataClob clob;
    begin
      vTheData:= XMLelement("empno",'1234567');
      vTheDataClob:= xmlelement("empno",'1234567').getclobval();
    end;
    Where as I can use below, but surely don't have to use select into from dual method. I just expect can use XMLElement function in plsql same as sql, such as most other functions eg length, rtrim etc.
    declare
    vTheData XMLType;
    vTheDataClob clob;
    begin
      select xmlelement("empno",'1234567')
      into vTheData
      from dual;
      select xmlelement("empno",'1234567').getclobval()
      into vTheDataClob
      from dual;
    end;
    Hope this makes sense.
    Thanks

    Having said that, is there a more elegant way to achieve below. That is populate two XML fragments and concatenate together.
    Sure, why not just only one statement?
    select XMLConcat(
             XMLElement( ... )
           , XMLElement( ... )
    into vTheResult
    from dual;
    As a second question, is it better to build and pass XML fragments as XMLType or clob?
    I would say stay with XMLType but it depends on your requirement.
    I generally avoid passing around pieces of data, SQL/XML functions are powerful in the way they can be used with set operations, so using them in a piecewise approach kinda negates what they're for.

  • Partial updates the Clob entries

    I have a xml stored in the Clob. it is just like follow,
    <employee>
    <corresponding_name>
    <fname>Kishor</fname>
    <lname>Sut</lname>
    <email>[email protected]</email>
    </corresponding_name>
    <contact_info>
    <home>4834342</home>
    <office>52345234</office>
    <mobile>986876856453</mobile>
    <pager>23534634</pager>
    </contact_info>
    </employee>
    Here I want to update the office phone of near about 100, 00 employee to new one. I can directly copy these xmls from toad, manually edit the office phone no, update the CLOB to EMPTY_CLOB() and upload this new xml again to CLOB using pl/sql. But it is not a wise solution, it's very time consuming and hectic and error-prone. Do any one have a easy solution for the same? Thanks in advance.
    Regards,
    Kamalnarayan Shrivastava

    Hi Kamal,
    Any idea about this???
    I am getting the following error,
    "ORA-20100: Error occurred while parsing: Error opening external DTD"
    while parsing the xml document.
    I am using Oracle api "sys.xmlparser.parsebuffer(p,xmlstrfinal);".
    Where xmlstrfinal is the xml with '<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE messages SYSTEM "testdtd.dtd">' header.
    I kept the dtd testdtd.dtd at location: /apps/oracle/admin/testserver/extproc/utl_file
    The detailed example is below,
    declare
         sqlquery varchar2(500);
         xmlstr clob;
         xmlstrfinal clob;
         xmlheaders varchar2(500);
         p xmlparser.Parser;
    begin
         xmlheaders:='<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE messages SYSTEM "testdtd.dtd">';
         sqlquery:='SELECT XMLCONCAT(
         xmlelement("emp",xmlattributes('||'''2'''||' AS "id")
         , xmlelement("number", 29590)
         , xmlelement("name", 29590)
         , xmlelement("salary", 65000)
         , xmlelement("ele1", 1)
         , xmlelement("ele2", 2)
         , xmlelement("ele3", 3)
         , xmlelement("ele4", 4)
         )).GetClobVal() from dual';
         EXECUTE IMMEDIATE sqlquery into xmlstr;
         xmlstrfinal := xmlheaders||xmlstr;
         --dbms_output.put_line(xmlstr.extract('/').getStringVal());
         dbms_output.put_line(xmlstrfinal);
         -- Create a parser.
         p:= sys.xmlparser.newParser;     
         --buff:=xmlstr.extract('/').getStringVal();
         --xmlparser.parse(p,buff);
         sys.xmlparser.setvalidationmode (p, FALSE);
         sys.xmlparser.parsebuffer(p,xmlstrfinal);
         sys.xmlparser.freeParser(p);
         -- p.parsebuffer(buff);     
         exception
              when others then
                   dbms_output.put_line('Error is: '||sqlerrm);
    end;
    Thanks in advance,
    Kamal Shrivastava

  • Generate schema-base XML from XML fragments

    I have a defined .xsd file and an incoming xml file that I am inspecting in a BEFORE INSERT trigger. I registered the xml schema to create a single column table of xmltype. The incoming xml consists of a root node and two data nodes. There are 3 elements on the first data node that need to have their value updated before the xml doc is inserted into the xmltype Oracle table.
    I was trying to find a way to use updateXML(), but that seems to work only for an existing row in the table. I then turned my attention to createXML(). I grabbed the root node and two data nodes and built 3 different clob's. One of the clob's contains an updated data node. Then I am doing the following:
    :new.sys_nc_rowinfo$ := createXML(clob1||clob2||clob3, registeredURL);
    registeredURL contains the URL that was registed in the schema. While it seems that the signature of the createXML() function is correct (I get no compile errors), the results are not valid per the schema. Is there a way in PL/SQL to do what I am trying to do? Seems like a pretty simple concept.

    Nikhil,
    There is a wealth of information available on the Internet regarding the XML capabilities of the Oracle database.
    Have you done an Internet search for "SQL XML Oracle"?
    Good Luck,
    Avi.

  • Updating the whole xml file in  XMLType column

    Hi ,
    I am facing the problem in updating the XMLTYPE column.
    I need to update the whole xml file
    This is my table
    SQL> desc EMPJAL_TABLE;
    Name Null? Type
    EMPLOYEEID NOT NULL VARCHAR2(140)
    EMPCOM VARCHAR2(100)
    EMPJAL SYS.XMLTYPE(XMLSchema "www.EMPSIM.com" Element "EMPJAL") STORAGE
    Object-relational TYPE "EMPJAL_T"
    I am able to form the CLOB object and trying to use this sql command
    UPDATE EMPJAL_TABLE SET EMPJAL = XMLType( ? ) ) WHERE EMPLOYEEID ='emp1234';
    Here I want to update the whole xmlfile in XMLTYPE column.
    Error is - ORA-00933: SQL command not properly ended
    Please advise
    Thanks
    Govinds

    Hi Mark,
    I apologise for this mistake. I am really putting lot of efforts and also worked/working in advance topics of XML DB.
    Yes I am extensively using Oracle 10g r2 and suggesting others to use this
    This time I had put more effort before posting ,I had a series of queries to resolve most of then were working , this was the one giving problem inside my java code
    I am sorry for this .
    Any how I made another query which works better.
    Thanks
    Govinda

  • Exception while updating a clob value using dbms_lob.fragment_insert

    Hi,
    Here is the query
    procedure tempProc(str3 in varchar2) is
    QI CLOB;
    -- LOB(QI) STORE AS securefile ;
    v_cursor refcursor;
    str varchar2(50);
    i number default '30';
    begin
    open v_cursor for select b.OCEAN_RATE_XML.getClobVal() from TNMAB_OCEAN_RATE_XML B
    WHERE (XMLCast(XMLQuery('declare default element namespace "http://com.oocl.schema.tnm.agreementbuilder"; (: :) /OceanOfferRate/ObjectID'
    PASSING B.OCEAN_RATE_XML RETURNING CONTENT) AS NUMBER(20))) = 200000000000050;
    fetch v_cursor into QI;
    close v_cursor;
    dbms_output.put_line('abcds'||DBMS_LOB.getlength(QI));
    dbms_lob.fragment_insert(QI,3,DBMS_LOB.getlength(QI)-17,'<abc/>');
    dbms_output.put_line('Done insert');
    DBMS_LOB.READ (QI, i, DBMS_LOB.getlength(QI)-i, str);
    --DBMS_LOB.READ(QI,20,DBMS_LOB.getlength(QI)-20,str);
    dbms_output.put_line('Doem read');
    dbms_output.put_line(str);
    end tempProc;
    I am getting the below exceptionError report:
    ORA-43856: Unsupported LOB type for SECUREFILE LOB operation
    ORA-06512: at "SYS.DBMS_LOB", line 1076
    ORA-06512: at "TNM_PLSQL.TNM_AB_QI_UPDT_PKG", line 377
    ORA-06512: at line 5
    ORA-06512: at line 9
    <OceanOfferRate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://com.oocl.schema.tnm.agreementbuilder">
    <ObjectID>200000000000050</ObjectID>
    <RateID>2</RateID>
    <AgreementID>00000002</AgreementID>
    <StartingVersion>0</StartingVersion>
    <EndingVersion>0</EndingVersion>
    <EffectiveFrom>2010-05-16T00:00:00.000000</EffectiveFrom>
    <EffectiveTo>2010-06-30T00:00:00.000000</EffectiveTo>
    <RateStatus>QuoteExpired</RateStatus>
    <ApprovalStatus>Approved</ApprovalStatus>
    <Flags>3</Flags>
    <Tariffs>015</Tariffs>
    <BaseRates>
    <SizeType>20GP</SizeType>
    <Amount>65</Amount>
    <Currency>USD</Currency>
    <EffectiveFrom>2010-05-16T00:00:00.000000</EffectiveFrom>
    <EffectiveTo>2010-06-30T00:00:00.000000</EffectiveTo>
    <Flags>0</Flags>
    </BaseRates>
    <BaseRates>
    <SizeType>40GP</SizeType>
    <Amount>100</Amount>
    <Currency>USD</Currency>
    <EffectiveFrom>2010-05-16T00:00:00.000000</EffectiveFrom>
    <EffectiveTo>2010-06-30T00:00:00.000000</EffectiveTo>
    <Flags>0</Flags>
    </BaseRates>
    <BaseRates>
    <SizeType>40HQ</SizeType>
    <Amount>100</Amount>
    <Currency>USD</Currency>
    <EffectiveFrom>2010-05-16T00:00:00.000000</EffectiveFrom>
    <EffectiveTo>2010-06-30T00:00:00.000000</EffectiveTo>
    <Flags>0</Flags>
    </BaseRates>
    <ShippingPartyGroupName>Default</ShippingPartyGroupName>
    <CustomerContactGroupName>Default</CustomerContactGroupName>
    <NamedCustomerGroupName>Default</NamedCustomerGroupName>
    <LastSentDate>2010-06-14T22:42:48.536000</LastSentDate>
    <ValidityDays>30</ValidityDays>
    <ValidityExpirationDate>2010-06-30T00:00:00.000000</ValidityExpirationDate>
    <GuidelineRateReference>
    <Trunk>
    <RateID>100001510668470</RateID>
    <SurchargeIDs>684172719752758</SurchargeIDs>
    <SurchargeIDs>626856918161564</SurchargeIDs>
    <SurchargeIDs>680028613161439</SurchargeIDs>
    <SurchargeIDs>679555629913553</SurchargeIDs>
    <SurchargeIDs>673382151283681</SurchargeIDs>
    <SurchargeIDs>679789705628181</SurchargeIDs>
    <SurchargeIDs>653835218283772</SurchargeIDs>
    <SurchargeIDs>653955477367768</SurchargeIDs>
    <SurchargeIDs>653955477367759</SurchargeIDs>
    </Trunk>
    </GuidelineRateReference>
    <CreatedOn>2010-05-16T13:40:29.201344</CreatedOn>
    <CreatedBy>KRISHSA</CreatedBy>
    <SalesPerson>COOKBR</SalesPerson>
    <SalesOffice>PHE</SalesOffice>
    <LastUpdated>2010-06-30T00:13:06.000000</LastUpdated>
    <LastUpdatedBy>TNM_APPLN</LastUpdatedBy>
    <Origins>
    <ID_Wrappers>
    <Value>100000000026067</Value>
    </ID_Wrappers>
    <ID_Wrappers>
    <Value>100000000008923</Value>
    </ID_Wrappers>
    <ID_Wrappers>
    <Value>100000000024173</Value>
    </ID_Wrappers>
    </Origins>
    <Destinations>
    <ID_Wrappers>
    <Value>100000000008923</Value>
    </ID_Wrappers>
    <ID_Wrappers>
    <Value>100000000024173</Value>
    </ID_Wrappers>
    <ID_Wrappers>
    <Value>100000000013006</Value>
    </ID_Wrappers>
    <ID_Wrappers>
    <Value>100000000046704</Value>
    </ID_Wrappers>
    </Destinations>
    <DeliveryMode>YY</DeliveryMode>
    <TradeLane>IAT</TradeLane>
    <Commodity>
    <Description>Cotton for test</Description>
    <CargoNatureGroup>32</CargoNatureGroup>
    </Commodity>
    <RateLevel>1</RateLevel>
    </OceanOfferRate>
    Any advise if there is any other ways to update the clob with additional information at the end of the XML before </OceanOfferRate> ?

    A quick example illustrating what I mean :
    Settings
    SQL> create table department_xml (
      2    xmldoc xmltype
      3  , depid  number(4) as
      4    (
      5      xmlcast(
      6        xmlquery('declare default element namespace "http://some.namespace.org"; (: :)
      7                  /Department/@ID' passing xmldoc returning content)
      8        as number(4)
      9      )
    10    ) virtual
    11  )
    12  xmltype xmldoc store as binary xml
    13  ;
    Table created.
    SQL> create unique index department_xml_depid_uix on department_xml (depid);
    Index created.
    SQL> insert into department_xml (xmldoc)
      2  select xmlelement("Department",
      3           xmlattributes('http://some.namespace.org' as "xmlns"
      4                        , department_id as "ID")
      5         , xmlforest(
      6             d.department_name as "departmentName"
      7           , d.manager_id as "managerID"
      8           , xmlforest(
      9               l.street_address as "street"
    10             , l.postal_code as "zipcode"
    11             , l.city as "city"
    12             , l.state_province as "state"
    13             , c.country_name as "country"
    14             ) as "address"
    15           )
    16         )
    17  from hr.departments d
    18       join hr.locations l on l.location_id = d.location_id
    19       join hr.countries c on c.country_id = l.country_id
    20  ;
    27 rows created.
    SQL> commit;
    Commit complete.
    Sample document
    SQL> select xmlserialize(document xmldoc as clob indent) from department_xml where depid = 50;
    XMLSERIALIZE(DOCUMENTXMLDOCASCLOBINDENT)
    <Department xmlns="http://some.namespace.org" ID="50">
      <departmentName>Shipping</departmentName>
      <managerID>121</managerID>
      <address>
        <street>2011 Interiors Blvd</street>
        <zipcode>99236</zipcode>
        <city>South San Francisco</city>
        <state>California</state>
        <country>United States of America</country>
      </address>
    </Department>
    Updating each doc with the list of employees from the corresponding department
    SQL> UPDATE department_xml d
      2  SET d.xmldoc =
      3      insertChildXMLBefore(
      4        d.xmldoc
      5      , '/Department'
      6      , 'address'
      7      , (
      8          select xmlelement("employees",
      9                   xmlagg(
    10                     xmlelement("employee",
    11                       xmlattributes(e.employee_id as "ID")
    12                     , xmlforest( e.first_name || ' ' || e.last_name as "employeeName"
    13                                , e.hire_date as "hireDate"
    14                                , e.salary as "salary" )
    15                     )
    16                     order by e.employee_id
    17                   )
    18                 )
    19          from hr.employees e
    20          where e.department_id = d.depid
    21        )
    22      , 'xmlns="http://some.namespace.org"'
    23      )
    24  ;
    27 rows updated.
    Checking...
    SQL> select xmlserialize(document xmldoc as clob indent) from department_xml where depid = 50;
    XMLSERIALIZE(DOCUMENTXMLDOCASCLOBINDENT)
    <Department xmlns="http://some.namespace.org" ID="50">
      <departmentName>Shipping</departmentName>
      <managerID>121</managerID>
      <employees>
        <employee ID="120">
          <employeeName>Matthew Weiss</employeeName>
          <hireDate>2004-07-18</hireDate>
          <salary>8000</salary>
        </employee>
        <employee ID="121">
          <employeeName>Adam Fripp</employeeName>
          <hireDate>2005-04-10</hireDate>
          <salary>8200</salary>
        </employee>
        <employee ID="122">
          <employeeName>Payam Kaufling</employeeName>
          <hireDate>2003-05-01</hireDate>
          <salary>7900</salary>
        </employee>
        <employee ID="123">
          <employeeName>Shanta Vollman</employeeName>
          <hireDate>2005-10-10</hireDate>
          <salary>6500</salary>
        </employee>
        <employee ID="124">
          <employeeName>Kevin Mourgos</employeeName>
          <hireDate>2007-11-16</hireDate>
          <salary>5800</salary>
        </employee>
        <employee ID="125">
          <employeeName>Julia Nayer</employeeName>
          <hireDate>2005-07-16</hireDate>
          <salary>3200</salary>
        </employee>
        <employee ID="126">
          <employeeName>Irene Mikkilineni</employeeName>
          <hireDate>2006-09-28</hireDate>
          <salary>2700</salary>
        </employee>
        <employee ID="127">
          <employeeName>James Landry</employeeName>
          <hireDate>2007-01-14</hireDate>
          <salary>2400</salary>
        </employee>
        <employee ID="128">
          <employeeName>Steven Markle</employeeName>
          <hireDate>2008-03-08</hireDate>
          <salary>2200</salary>
        </employee>
        <employee ID="129">
          <employeeName>Laura Bissot</employeeName>
          <hireDate>2005-08-20</hireDate>
          <salary>3300</salary>
        </employee>
        <employee ID="130">
          <employeeName>Mozhe Atkinson</employeeName>
          <hireDate>2005-10-30</hireDate>
          <salary>2800</salary>
        </employee>
        <employee ID="131">
          <employeeName>James Marlow</employeeName>
          <hireDate>2005-02-16</hireDate>
          <salary>2500</salary>
        </employee>
        <employee ID="132">
          <employeeName>TJ Olson</employeeName>
          <hireDate>2007-04-10</hireDate>
          <salary>2100</salary>
        </employee>
        <employee ID="133">
          <employeeName>Jason Mallin</employeeName>
          <hireDate>2004-06-14</hireDate>
          <salary>3300</salary>
        </employee>
        <employee ID="134">
          <employeeName>Michael Rogers</employeeName>
          <hireDate>2006-08-26</hireDate>
          <salary>2900</salary>
        </employee>
        <employee ID="135">
          <employeeName>Ki Gee</employeeName>
          <hireDate>2007-12-12</hireDate>
          <salary>2400</salary>
        </employee>
        <employee ID="136">
          <employeeName>Hazel Philtanker</employeeName>
          <hireDate>2008-02-06</hireDate>
          <salary>2200</salary>
        </employee>
        <employee ID="137">
          <employeeName>Renske Ladwig</employeeName>
          <hireDate>2003-07-14</hireDate>
          <salary>3600</salary>
        </employee>
        <employee ID="138">
          <employeeName>Stephen Stiles</employeeName>
          <hireDate>2005-10-26</hireDate>
          <salary>3200</salary>
        </employee>
        <employee ID="139">
          <employeeName>John Seo</employeeName>
          <hireDate>2006-02-12</hireDate>
          <salary>2700</salary>
        </employee>
        <employee ID="140">
          <employeeName>Joshua Patel</employeeName>
          <hireDate>2006-04-06</hireDate>
          <salary>2500</salary>
        </employee>
        <employee ID="141">
          <employeeName>Trenna Rajs</employeeName>
          <hireDate>2003-10-17</hireDate>
          <salary>3500</salary>
        </employee>
        <employee ID="142">
          <employeeName>Curtis Davies</employeeName>
          <hireDate>2005-01-29</hireDate>
          <salary>3100</salary>
        </employee>
        <employee ID="143">
          <employeeName>Randall Matos</employeeName>
          <hireDate>2006-03-15</hireDate>
          <salary>2600</salary>
        </employee>
        <employee ID="144">
          <employeeName>Peter Vargas</employeeName>
          <hireDate>2006-07-09</hireDate>
          <salary>2500</salary>
        </employee>
        <employee ID="180">
          <employeeName>Winston Taylor</employeeName>
          <hireDate>2006-01-24</hireDate>
          <salary>3200</salary>
        </employee>
        <employee ID="181">
          <employeeName>Jean Fleaur</employeeName>
          <hireDate>2006-02-23</hireDate>
          <salary>3100</salary>
        </employee>
        <employee ID="182">
          <employeeName>Martha Sullivan</employeeName>
          <hireDate>2007-06-21</hireDate>
          <salary>2500</salary>
        </employee>
        <employee ID="183">
          <employeeName>Girard Geoni</employeeName>
          <hireDate>2008-02-03</hireDate>
          <salary>2800</salary>
        </employee>
        <employee ID="184">
          <employeeName>Nandita Sarchand</employeeName>
          <hireDate>2004-01-27</hireDate>
          <salary>4200</salary>
        </employee>
        <employee ID="185">
          <employeeName>Alexis Bull</employeeName>
          <hireDate>2005-02-20</hireDate>
          <salary>4100</salary>
        </employee>
        <employee ID="186">
          <employeeName>Julia Dellinger</employeeName>
          <hireDate>2006-06-24</hireDate>
          <salary>3400</salary>
        </employee>
        <employee ID="187">
          <employeeName>Anthony Cabrio</employeeName>
          <hireDate>2007-02-07</hireDate>
          <salary>3000</salary>
        </employee>
        <employee ID="188">
          <employeeName>Kelly Chung</employeeName>
          <hireDate>2005-06-14</hireDate>
          <salary>3800</salary>
        </employee>
        <employee ID="189">
          <employeeName>Jennifer Dilly</employeeName>
          <hireDate>2005-08-13</hireDate>
          <salary>3600</salary>
        </employee>
        <employee ID="190">
          <employeeName>Timothy Gates</employeeName>
          <hireDate>2006-07-11</hireDate>
          <salary>2900</salary>
        </employee>
        <employee ID="191">
          <employeeName>Randall Perkins</employeeName>
          <hireDate>2007-12-19</hireDate>
          <salary>2500</salary>
        </employee>
        <employee ID="192">
          <employeeName>Sarah Bell</employeeName>
          <hireDate>2004-02-04</hireDate>
          <salary>4000</salary>
        </employee>
        <employee ID="193">
          <employeeName>Britney Everett</employeeName>
          <hireDate>2005-03-03</hireDate>
          <salary>3900</salary>
        </employee>
        <employee ID="194">
          <employeeName>Samuel McCain</employeeName>
          <hireDate>2006-07-01</hireDate>
          <salary>3200</salary>
        </employee>
        <employee ID="195">
          <employeeName>Vance Jones</employeeName>
          <hireDate>2007-03-17</hireDate>
          <salary>2800</salary>
        </employee>
        <employee ID="196">
          <employeeName>Alana Walsh</employeeName>
          <hireDate>2006-04-24</hireDate>
          <salary>3100</salary>
        </employee>
        <employee ID="197">
          <employeeName>Kevin Feeney</employeeName>
          <hireDate>2006-05-23</hireDate>
          <salary>3000</salary>
        </employee>
        <employee ID="198">
          <employeeName>Donald OConnell</employeeName>
          <hireDate>2007-06-21</hireDate>
          <salary>2600</salary>
        </employee>
        <employee ID="199">
          <employeeName>Douglas Grant</employeeName>
          <hireDate>2008-01-13</hireDate>
          <salary>2600</salary>
        </employee>
      </employees>
      <address>
        <street>2011 Interiors Blvd</street>
        <zipcode>99236</zipcode>
        <city>South San Francisco</city>
        <state>California</state>
        <country>United States of America</country>
      </address>
    </Department>

  • Update passed in XML doc with pl/sql xmldom

    Hi,
    I have an xml document that is passed in through a stored procedure as CLOB. I'm trying to use the XMLParser and XMLDOM to add an additional node
    The XML looks something like the following
    <rowset>
    <row>
    <firstname>john</firstname>
    </row>
    <row>
    <firstname>jane</firstname>
    </row>
    </rowset>
    I need to loop through each of <mynames> nodes and then add another node <lastame> so it looks like the following
    <rowset>
    <row>
    <firstname>john</firstname>
    <lastame>smith</lastame>
    </row>
    <row>
    <firstname>jane</firstname>
    <lastame>smith</lastame>
    </row>
    </rowset>
    I have the following code
    parseClob XMLPARSER.Parser;
    newNames XMLDOM.DOMDocument;
    tempNode XMLDOM.DOMNode;
    mye xmldom.domelement;
         item_text xmldom.DOMText;
    numofrows number;
         nodeList xmldom.DOMNodeList;
         newnode xmldom.domnode;
    parseClob := xmlparser.newParser;
    XMLPARSER.parseClob(parseClob,names);
    newNames := XMLPARSER.getDocument(parseClob);
    XMLPARSER.freeParser(parseClob);
    nodeList := xslprocessor.selectNodes(xmldom.makeNode(newNames), '//rowset/row');
    numOfRows := xmldom.getlength(nodeList)-1;
    for i in 0..numOfRows LOOP
    newnode := xmldom.item(nodeList, i);
              --create the new node
    mye := xmldom.createElement(newName, 'lastname');
    --add it to the new node   
    tempNode := xmldom.appendChild(newnode, xmldom.makeNode(mye));
    --update the text in the lastname   
    item_text := xmldom.createTextNode(newNames, 'smith');
    tempNode := xmldom.appendChild(tempNode, xmldom.makeNode(item_text));
    end loop;
    what happens is that when i write out the newnode xml out to a buffer i see the <lastname> tag
    but when i write out the newNames xml out to a buffer after the loop is finished the <lastname> tag is
    missing. like it didn't update the newNames xml
    I've seen lots of example on how to create an XML document with the DOM from scratch but nothing about updating
    an passed in xml document. any help would be appreciated

    Updatexml is reference in Oracle 9i, I'm sorry i should have mentioned that I am using oracle 8i. Is there something you can use in oracle 8i?

  • How to include a URL in an XML fragment

    Hello , my general question is how can I include a URL as a literal in an XML fragment , I tried this(please look at the bold part) but it would'nt work , I am getting a compile error because supposedly "<" is a special character in XML so how do I escape it or indeed how do I represent my URL? Your help is highly appreciated
    <EndpointReference xmlns="http://schemas.xmlsoap.org/ws/2003/03/addressing [b]<https://webmail.bearingpoint.com/exchweb/bin/redir.asp?URL=http://schemas.xmlsoap.org/ws/2003/03/addressing> ">
    <Address>https://secure-ausomxbxa.crmondemand.com/Services/Integration;j <https://webmail.bearingpoint.com/exchweb/bin/redir.asp?URL=https://secure-ausomxbxa.crmondemand.com/Services/Integration;j> sessionid=</Address>
    <ServiceName xmlns:ns1="urn:crmondemand/ws/opportunity/10/2004">ns1:Opportunity</ServiceName>
    </EndpointReference>

    I don't know why you would want to surround your URL with < and > characters.
    But the XML rule for escaping those characters in text nodes and attributes is that you escape < as < and > as >. The fact that URLs are involved in your case doesn't make any difference to that rule.
    And normally if you're using XML software (e.g. Transformer, or Xerces's serializer) to write the document, it will take care of that detail for you. On the other hand if you're using ordinary java.io classes to write the document, you have to apply that rule yourself.

  • Java.sql.SQLException:ORA-01407: cannot update ("WAVESET", "TASK", "XML")

    Hi,
    We are currently facing the above mentioned error while trying to install Sun IdM 7.1 in WebSphere 6.0. The same ear works fine in all my other environments (all are WebSphere 5). This is what we did
    1. Took a copy of the ear thats works.
    2. Extract.
    3. Modified the serverrepository.xml by using the lh command. Use the newly generated xml file in the extracted folder (WEB-INF), Pack it to a new EAR
    4. Configure the datasource that will be used to communicate with the Index repository.
    5. Deploy.
    Deployment completes successfully. However, when we try to run a task, or import file using IdM admin console, we get this error 'java.sql.SQLException:ORA-01407: cannot update ("WAVESET", "TASK", "XML") to NULL'. we even checked the user permissions on this db schema. they all look good.
    We also checked if we are using the right iiop port number in lh command.
    We arent sure what could be the issue. I am not able to simulate this issue in other environment, as they all turn out to be successful.
    any pointers?
    thanks.

    I still think it's a jdbc error.what is your DB platform?
    is you ServerRepository.xml configured with a jndi data source (and that's why you use iiop)? If so then try to create a new connection through a direct DB URL like:
    lh setRepo -tDBTYPE -uURL -Uusername -Ppassword -n -oServerRepository.xml
    and then try to re-run your update command. if it fails again then please post the complete error message.. hope this helps

  • Xml-fragment Issue retrieving Nested element data

    Hi,
    I've problem retrieving the nested element data from the xml. Using XmlBeans I am getting null when retriving the inner element. I printed the nested element xmlobject it has Xml-Fragment wrapped. I tired using below code it doesn't throw any error but the data is lost
    AAAA TempObj=AAAA.getBXXX().getCXXX(0);
    //remove xml fragment
    XmlOptions xmlOpt = new XmlOptions();
    xmlOpt.setSaveOuter();
    XmlCursor c= TempObj.newCursor();
    c.toFirstChild();
    Myclass myclassObj= Myclass.Factory.parse(c.getObject().xmlText(xmlOpt));
    log.debug("Records: "+myclassObj .getXXArray().length);
    Output:
    length should give aleast 1 or more but I am getting 0. That means the xmltext didn't parse properly.
    Can anybody suggest what could be the problem.
    Thanks in advance.
    -Sri

    no answer

  • BPEL Designer "Assign" Activity XML Fragment Formatting

    When attempting to compile a simple process to return the text of an XML string literal, the compiler throws a BPEL-10900 error. XMLSpy shows the same XML fragment as being both well-formed and valid. Why the disparity?

    Hi,
    can you publish this question on the BPEL forum here on OTN. I think that this question requires some follow up interaction.
    BPEL
    Frank

Maybe you are looking for

  • Outlook 2013 crashes when collapsing shared calendar

    The following issues occurs when viewing shared calendars with Outlook 2013. It occurs on multiple workstations and with multiple users. When collapsing a shared calendar by clicking the arrow to the left of the calendar name, if one or more users of

  • Linking two remote Macs

    I have a basic question about linking two remote Macs over the internet. Here's the situation... I live in Maryland and my brother in South Carolina. We would like to be able to exchange large files easily. I've managed to do this using sftp from the

  • UTL_FILE: Reading and Writing client-side Files

    Hi All, Please tell me how to read & write UTL_FILE at client-side Regards

  • What makes an idocs go out of SAP to external systems.

    Hi Experts, I have created many idocs in sap. they are in status of 03 meaning ready to be transmitted. but they don't go out of sap, they still remain in queue in sm58. If i process it manually it is going. but it should be done automatically. what

  • My mobile-me email accout does not receieve any emails and does not show the file system

    hi - my mobile me email account does not recieve any emails - plus, the file structur is not available on my mac. I am using iphone and ipad, there at least the file structure is visible. I received the notification, that my icloud storage is not suf