XML Update

I have a question for updating an xml document.
I will show it on an example. I have follow xml document as xml type in the db.
<EMPLOYEES>
<EMP>
<EMPNO>112</EMPNO>
<EMPNAME>Joe</EMPNAME>
<SALARY>50000</SALARY>
</EMP>
<EMP>
<EMPNO>217</EMPNO>
<EMPNAME>Jane</EMPNAME>
<SALARY>60000</SALARY>
</EMP>
<EMP>
<EMPNO>412</EMPNO>
<EMPNAME>Jack</EMPNAME>
<SALARY>40000</SALARY>
</EMP>
</EMPLOYEES>
I know how to update the existing elements(change the EMPNAME or SALSRY) but how can i add a new EMP. The result should like this:
<EMP>
<EMPNO>112</EMPNO>
<EMPNAME>Joe</EMPNAME>
<SALARY>50000</SALARY>
</EMP>
<EMP>
<EMPNO>217</EMPNO>
<EMPNAME>Jane</EMPNAME>
<SALARY>60000</SALARY>
</EMP>
<EMP>
<EMPNO>412</EMPNO>
<EMPNAME>Jack</EMPNAME>
<SALARY>40000</SALARY>
</EMP>
<--begin new element -->
<EMP>
<EMPNO>111</EMPNO>
<EMPNAME>NEW</EMPNAME>
<SALARY>1111</SALARY>
</EMP>
<-- end new element -->
</EMPLOYEES>
Is this possible with XMLupdate???

Today in 9.2 and 10.1 you have to the DBMS_XMLDOM package. In 10.2 there will be new SQL functions insertChildXML(), appendChildXML() deleteXML() to do this

Similar Messages

  • Re:XML update

    Hello Gurus ,
    i want to write a procedure for xml update ,
    consider,
    a table department consisting depart_no,depart_name,emp_Personal_info here emp_personal_info is a column of xmltype
    having data like (for a single department)(FOR DEPTNO 5801)
    <EMP>
      <EMPPERSONALINFO>
        <id>1</id>
        <name>x1</name>
        <join_date>12/2/2013</join_date>
        <work_station_no>LYH043897</work_station_no>
        <date_of_birth>2/2/1982</date_of_birth>
      </EMPPERSONALINFO>
      <EMPPERSONALINFO>
        <id>2</id>
        <name>x2</name>
        <join_date>2/5/2013</join_date>
        <work_station_no>LYH043898</work_station_no>
        <date_of_birth>30/5/1982</date_of_birth>
      </EMPPERSONALINFO>
    </EMP>a each department is holding information of over 100 employees(up to <id>100</id>)
    now i want to update emppersonal info with a new attribute <mainbranch>with a default data based on department number
    required output:
    <EMP>
      <EMPPERSONALINFO>
        <id>1</id>
        <name>x1</name>
        <join_date>12/2/2013</join_date>
        <work_station_no>LYH043897</work_station_no>
        <date_of_birth>2/2/1982'</date_of_birth>
        <mainbranch>CZDS</MAINBRANCH>
      </EMPPERSONALINFO>
      <EMPPERSONALINFO>
        <id>2</id>
        <name>x2</name>
        <join_date>2/5/2013</join_date>
        <work_station_no>LYH043898</work_station_no>
        <date_of_birth>30/5/1982</date_of_birth>
      <mainbranch>CZDS</MAINBRANCH>
      </EMPPERSONALINFO>
    </EMP>kindly guide me,
    regards,
    friend

    Hi,
    What's the database version?
    You've posted enough here to know how to properly ask a question.
    now i want to update emppersonal info with a new attribute <mainbranch>with a default data based on department numberYou wouldn't have such issue if the data model was correctly designed in the first place, using 3rd NF, i.e. with a separate child table to hold employee information.
    You can use insertchildXML or appendChildXML functions :
    SQL> update department t
      2  set t.emp_personal_info =
      3      insertchildxml(
      4        t.emp_personal_info
      5      , '/EMP/EMPPERSONALINFO'
      6      , 'mainbranch'
      7      , xmlelement("mainbranch", 'D' || t.dept_no)
      8      )
      9  where t.dept_no = 5801 ;
    1 row updated
    SQL> set long 5000
    SQL> select xmlserialize(document emp_personal_info indent) from department;
    XMLSERIALIZE(DOCUMENTEMP_PERSO
    <EMP>
      <EMPPERSONALINFO>
        <id>1</id>
        <name>x1</name>
        <join_date>12/2/2013</join_date>
        <work_station_no>LYH043897</work_station_no>
        <date_of_birth>2/2/1982</date_of_birth>
        <mainbranch>D5801</mainbranch>
      </EMPPERSONALINFO>
      <EMPPERSONALINFO>
        <id>2</id>
        <name>x2</name>
        <join_date>2/5/2013</join_date>
        <work_station_no>LYH043898</work_station_no>
        <date_of_birth>30/5/1982</date_of_birth>
        <mainbranch>D5801</mainbranch>
      </EMPPERSONALINFO>
    </EMP>
    These XML DML functions are deprecated as of 11.2.0.3 in favor of XQuery Update.

  • ITunes tantrum - xml update, lost songs, data1.cab errors

    Hi All,
    In the last couple of days my iTunes has thrown a real tantrum.
    When I switched on iTunes on the PC two days ago, it didn't come up straight away, instead it said it was updating the XML. This went on for ages, so thinking it was just one of those wonky start-ups, I hit cancel and loaded it again - the result half my songs were missing - about 3500 gone.
    I had a back-up of the xml & library so I brought those in and ran iTunes again - this time when it did its xml update I let it finish.
    The result was that all the songs added in the last month were gone - so I re-added them.
    The next day I opened it up and the new songs were gone. (It's a 40gb iPod photo, with about 30gb used).
    I decided to update iTunes from v6 to v7 to see if that helped.
    The upload kept failing (sulking about the iTunes & Quicktime .cab files), but after repeated tries it eventually went through.
    I was able to use it that night and re-loaded most of the songs.
    I tried to open iTunes this morning and it tells me that I haven't got Quicktime v7.1.3 installed only v7.1 - however I have checked and I do have v7.1.3 installed.
    I've tried to re-download the 34mb iTunes 7 setup exe from the Apple site and all it sends is an uncertified file of varying size between 70 & 700mb, which can't run anyway.
    I tried loading the original iTunes software from the disk, but it's kicked out straight away due to a later version being in place.
    Please help, I've tried all the options my tiny brain can offer.
    Thanks,
    Paul

    Paul,
    Whilst it's possible you may get help in this Forum, you have a much better chance if you re post in the iTunes/Windows forum which is here.
    http://discussions.apple.com/forum.jspa?forumID=792
    There are experts there who rarely visit the iPod forums.

  • ITunes tantrum - xml update, lost songs, not recognising new Quicktime

    Hi All,
    In the last couple of days my iTunes has thrown a real tantrum.
    When I switched on iTunes on the PC two days ago, it didn't come up straight away, instead it said it was updating the XML. This went on for ages, so thinking it was just one of those wonky start-ups, I hit cancel and loaded it again - the result half my songs were missing - about 3500 gone.
    I had a back-up of the xml & library so I brought those in and ran iTunes again - this time when it did its xml update I let it finish.
    The result was that all the songs added in the last month were gone - so I re-added them.
    The next day I opened it up and the new songs were gone. (It's a 40gb iPod photo, with about 30gb used).
    I decided to update iTunes from v6 to v7 to see if that helped.
    The upload kept failing (sulking about the iTunes & Quicktime .cab files), but after repeated tries it eventually went through.
    I was able to use it that night and re-loaded most of the songs.
    I tried to open iTunes this morning and it tells me that I haven't got Quicktime v7.1.3 installed only v7.1 - however I have checked and I do have v7.1.3 installed.
    I've tried to re-download the 34mb iTunes 7 setup exe from the Apple site and all it sends is an uncertified file of varying size between 70 & 700mb, which can't run anyway.
    I tried loading the original iTunes software from the disk, but it's kicked out straight away due to a later version being in place.
    Please help, I've tried all the options my tiny brain can offer.
    Thanks,
    Paul

    Paul,
    Whilst it's possible you may get help in this Forum, you have a much better chance if you re post in the iTunes/Windows forum which is here.
    http://discussions.apple.com/forum.jspa?forumID=792
    There are experts there who rarely visit the iPod forums.

  • How to update combobox that with xml source binding when xml updated in Powershell

    I'm just newbie to WPF & Powershell. Currently have a Powershell program with XAML UI. Herein a combobox control binding a xml file. The problem lays in how can I update the combobox once xml updated? Thanks in advance!

    Hello sihat,
    I've read some articles about using PowerShell and WPF:
    https://msdn.microsoft.com/en-us/magazine/hh288074.aspx
    http://blogs.technet.com/b/heyscriptingguy/archive/2014/04/06/weekend-scripter-build-a-clock-widget-by-using-powershell-and-wpf.aspx
    It seems the steps are all related to using PowerShell to create WPF UI. As the script comes from PowerShell I would think that PowerShell related forum may much better.
    I will introduce things in WPF, if you want to make UI update based on your source,  the source must implement a suitable property change notification mechanism such as
    INotifyPropertyChanged. See
    How to: Implement Property Change Notification for an example of an
    INotifyPropertyChanged implementation.
    For more details about this WPF scenario, please see WPF databinding:
    https://msdn.microsoft.com/en-us/library/ms752347(v=vs.110).aspx
    If you want to do the same in PowerShell, please consider to post on PowerShell related forum to ask how you can write the same script.
    Best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • HTML Tags in XML Update

    I have a unique situation (may be not that unique). I want to update or add HTML tags in an XML element I am writing a PL/SQL Stored Procedure to insert, update or delete elements/attributes from an XML Type column based on the input XML (coming from Java application). SP is called from Java app. For example my XML may loook like
    <Description Name="Sales Message">
    <Text>This is a test</Text>
    </Description>
    I can update this in XML by creatinga SP which accepts a value (clob or text) and make a simple update call like
    UPDATE table_name
    SET hotel_xml = UPDATEXML (hotel_xml, Description[@Name=''Sales Message'']/Text/text()', 'This is a Test')
    WHERE id = 123;
    Hopwever when I have HTML tags in my parameter value, my update fails. For example java pp passes me a string
    This is a bold &lt;B&gt;Test&lt;/B&gt;
    (without encoding it is "This is a Bold <B>Test</B>"
    When I run this
    UPDATE table_name
    SET hotel_xml = UPDATEXML (hotel_xml, Description[@Name=''Sales Message'']/Text/text()', 'This is a bold &lt;B&gt;Test&lt;/B&gt;')
    WHERE id = 123;
    It thinks, I am passing a substitution variable (think &lt and &gt as sub variables) and the procedure fails.
    How do I handle HTML encoded charcters in Oarcle Pl/SQL? Many of my SPs has to accept XML as clob that may contain HTML encoding. Java always encodes HTML tags in an XML so I have to pass the CLOB(xml) to a SP as it is

    When this type of encoding is there in my XML or input variable, PL/SQL thinks
    its a substitution variable and tries to replace it by prompting replacement. I think »substitution variables« is the wrong phrase for this. Probably you mean »entity names«, and all that happens is that special characters are converted to »entity names« to ensure valid xml after the update:
    SQL> with table_name as (
    select xmltype('<Description Name="Sales Message">
                       <Text>This is a test</Text>
                     </Description>') hotel_xml from dual)
    select updatexml (hotel_xml,
                      'Description[@Name="Sales Message"]/Text/text()',
                      'This is a bold <B>Test</B>'
                     ) hotel_xml
      from table_name
    HOTEL_XML                                                                                             
    <Description Name="Sales Message"><Text>This is a bold &amp;lt;B&amp;gt;Test&amp;lt;/B&amp;gt;</Text></Description> Do you expect your result to look like
    <Description Name="Sales Message">
      <Text>This is a bold <B>Test</B></Text>
    </Description>??

  • XML update a query?

    Hey, I'm trying to get an xml query to work which when you click a button will load the next items on the xml structure.
    so like
    private var currentQueryNumber : uint = 0;
    private function updateQuery(no:uint){
         {currentQueryNumber + 1};}
    isn't right...
    Anyone able to help me in what I should be putting.

    I think we need more details, and simplified yet "complete" code.
    How is currentQueryNumber used to update the query?
    Need more details.

  • XML updating --Urgent!

    Hi,
    I'm able to extract the Document out of the XML stored in the DB. I'm doing some changes like inserting new elements and removing some elements from the Document. How do I save the new Document back to the database?
    The following is the code fragment:
    String queryStr = "select e.xmlcol from TEMP_XML_AP e where e.fname='pid_cn_cn_ap_all_big.series_u_1115.xml'";
    OraclePreparedStatement ostmt = (OraclePreparedStatement)con.prepareStatement(queryStr);
    ResultSet rs = ostmt.executeQuery();
    OracleResultSet orset = (OracleResultSet)rs;
    while(orset.next())
    {  OPAQUE op = orset.getOPAQUE(1);
    XMLType theXML = XMLType.createXML(op);//;
    Document doc = (Document)theXML.getDOM();
    //add new element
    doc.createTextNode("TEST");
    //remove child
    doc.removeChild("xyz");
    Please tell me how to store back the updated document.
    Thanks

    You'll have a lot more luck with this question on dot.net
    forum than here.
    I use dot.net to return xml, but I have never used
    XMLSerializer.
    Tracy

  • How to automate managed beans.xml update

    I am using JSC 2.0 ea and am trying to add a "loginBean" based on the example in java studio creator field guide. The process explained in the book, ie right-click "source package" add java package, right-click newly created package and add "managed bean" - this does not exist in jsc 2.0, so when you add a class file the managed-beans.xml file is not updated - is their an automated process to add a managed bean in jsc 2.0?

    Hi,
    Please post messages related to Creator 2 EA at the feedbacks programs portal. The URL is:
    https://feedbackprograms.sun.com/login.html
    Thanks,
    Creator Team

  • Can XML Update more than One Table in one call?

    Hello,
    I had a quick question. I have a client who is using both Oracle and SQL. They have an app developed in C sharp with XML whichs runs against SQL and want to port to Oracle.
    In SQL one XML statment can update multiple Tables. Can we do that in XML in Oracle? I know, we can't do that using PL/SQL.
    Subhash

    Anupama,
    Thanks for offering your help. I have attached the sample code. It works fione on SQL. I need to make sure it works on Oracle as well.
    Subhash
    ALTER PROCEDURE dbo.spx_PutPackage
    @XMLText text
    AS
    DECLARE @hDoc int,
    @Package_Tbl_Id Int,
    @Package_Type_Id Int,
    @Binder_Id Int,
    @Package_Name Varchar(256),
    @Package_Status_Type_Id Int,
    @Package_Approval_SeqNo Int,
    @Package_Current_Issue Int
    BEGIN
    --******************************** DELETE ********************************
    EXEC sp_xml_preparedocument @hDoc OUTPUT, @XMLText
    DECLARE xml_cursor
    CURSOR FOR
    SELECT Package_Tbl_Id,Package_Type_Id,Binder_Id
    FROM openxml(@hDoc,'/ROOT/Package[@Package_Status="D"]')
    With Package
    OPEN xml_cursor
    FETCH NEXT FROM xml_cursor INTO @Package_Tbl_Id,@Package_Type_Id,@Binder_Id
    WHILE @@fetch_status = 0
    BEGIN
    DELETE Package WHERE Package_tbl_Id = @Package_Tbl_Id
    --If this package is an addendum, a trigger decrements the Current_Addendum_Number
    --when the addendum table is deleted as part of the cascade delete.
    FETCH NEXT FROM xml_cursor INTO @Package_Tbl_Id,@Package_Type_Id,@Binder_Id
    End
    Close xml_cursor
    DEALLOCATE xml_cursor
    --******************************** INSERT ********************************
    DECLARE xml_cursor
    CURSOR FOR
    SELECT
    Package_Tbl_Id,
    Package_Type_Id,
    Binder_Id,
    Package_Name,
    Package_Status_Type_Id,
    Package_Approval_SeqNo,
    Package_Current_Issue
    FROM openxml(@hDoc,'/ROOT/Package[@Package_Status="I"]')
    With Package
    OPEN xml_cursor
    FETCH NEXT FROM xml_cursor INTO
    @Package_Tbl_Id,
    @Package_Type_Id,
    @Binder_Id,
    @Package_Name,
    @Package_Status_Type_Id,
    @Package_Approval_SeqNo,
    @Package_Current_Issue
    WHILE @@fetch_status = 0
    BEGIN
    INSERT INTO Package (Package_Tbl_Id, Package_Type_Id, Binder_Id, Package_Name,
    Package_Status_Type_Id, Package_Approval_SeqNo, Package_Current_Issue)
    VALUES(@Package_Tbl_Id,
    @Package_Type_Id, @Binder_Id, @Package_Name, @Package_Status_Type_Id,
    @Package_Approval_SeqNo, @Package_Current_Issue)
    FETCH NEXT FROM xml_cursor INTO
    @Package_Tbl_Id,
    @Package_Type_Id,
    @Binder_Id,
    @Package_Name,
    @Package_Status_Type_Id,
    @Package_Approval_SeqNo,
    @Package_Current_Issue
    End
    Close xml_cursor
    DEALLOCATE xml_cursor
    --******************************** UPDATE ********************************
    DECLARE xml_cursor
    CURSOR FOR
    SELECT
    Package_Tbl_Id,
    Package_Type_Id,
    Binder_Id,
    Package_Name,
    Package_Status_Type_Id,
    Package_Approval_SeqNo,
    Package_Current_Issue
    FROM openxml(@hDoc,'/ROOT/Package[@Package_Status="U"]')
    With Package
    OPEN xml_cursor
    FETCH NEXT FROM xml_cursor INTO
    @Package_Tbl_Id,
    @Package_Type_Id,
    @Binder_Id,
    @Package_Name,
    @Package_Status_Type_Id,
    @Package_Approval_SeqNo,
    @Package_Current_Issue
    WHILE @@fetch_status = 0
    BEGIN
    Update Package
    SET
    Package_Type_Id = @Package_Type_Id,
    Binder_Id = @Binder_Id,
    Package_Name = @Package_Name,
    Package_Status_Type_Id = @Package_Status_Type_Id,
    Package_Approval_SeqNo = @Package_Approval_SeqNo,
    Package_Current_Issue = @Package_Current_Issue
    WHERE Package_tbl_Id = @Package_tbl_Id
    FETCH NEXT FROM xml_cursor INTO
    @Package_Tbl_Id,
    @Package_Type_Id,
    @Binder_Id,
    @Package_Name,
    @Package_Status_Type_Id,
    @Package_Approval_SeqNo,
    @Package_Current_Issue
    End
    Close xml_cursor
    DEALLOCATE xml_cursor
    EXEC sp_xml_removedocument @hDoc
    exec spx_putattachment @XMLText
    End
    SET QUOTED_IDENTIFIER ON

  • XML updated by php

    i write everything in this zip archive and explaine more
    detailed what i want to do
    please help me.i whant to update xml list with php
    http://rapidshare.com/files/75860277/MP3.zip
    please help

    i write everything in this zip archive and explaine more
    detailed what i want to do
    please help me.i whant to update xml list with php
    http://rapidshare.com/files/75860277/MP3.zip
    please help

  • Loop through xml, update field values and write to a file

    I have the following xml file:
    <candy>
    <product><column name="Data">123</column>
    <column name="Date">2002-1-1</column>
    </product>
    <product><column name="Data">456</column>
    <column name="Date">2002-1-1</column>
    </product></candy>
    I need to update column name="Date" from its current values to a new value and then write it to a file in java. I know the steps is to build a dom tree - xml parser-xpath ect. Can anyone provide some working examples or links? I did some search on web, but could not find any examples that meet my requirements.
    Thank you for your input.

    Here's a starting point for you:
    http://java.sun.com/webservices/docs/1.0/tutorial/doc/JAXPDOM3.html

  • Anyconnect Profile XML update

    Is there a way to force clients that are already installed to download an updated client profile XML file from the ASA.  I have tried editing the existing client profile xml file on the ASA, but the already deployed clients do not seem to download the changes.

    Have you tried going into the group policy that the clients use, deselect "Inherit" under "Client Profiles to Download" and specifiying your updated policy?
    Reference Figure 2-17 here. (Different policy but same concept.)

  • XML Update Element Text

    I am struggling to find an example of how to update an already existing elment text value. I can load the XML string without a problem, but I would like to change that single element of the XML string and output the whole string with the change. Can someone point me in the right direction?
    <?xml version="1.0" encoding="utf-8"?>
    <TestStructure>
    <Sample>0</Sample>
    </TestStructure>
    as the input, and then
    <?xml version="1.0" encoding="utf-8"?>
    <TestStructure>
    <Sample>[UPDATED VALUE]</Sample>
    </TestStructure>
    as the output.
    Thank you.

    Hi,
    You can update the xml by using labVIEW drivers also.
    This is also one of the way...
    Try it.
    <<Kudos are welcome>>
    ELECTRO SAM
    For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.
    - John 3:16
    Attachments:
    Xml.vi ‏8 KB

  • XML updating between FCP & Logic: DP has it, does Logic?

    Hello,
    While at NAMM, I watched the Digital Performer 6 and they touted a great feature. If you have both DP open AND FCP open, and are working on the same project, whatever you do in FCP will automatically be updated in DP, and vice versa. I think they called it XML interchange, or something like that, but they made sure to state that if you have BOTH programs running at the same time on the same project, any edits you do in one will be updated in the other! VERY COOL!
    Does Logic has this feature as well? According to the manual, Logic will import/export XML files, but unless I missed it, it doesn't say anything about the ability to automatically update the same project if both programs are running. I find it difficult to believe that DP would come out with this before Logic, so I though I'd ask more knowledge users if Logic has such a feature. Thank you very much for your reply!

    For those interested, here is part of an article on how DP's XML interchange works: http://namm.harmony-central.com/WNAMM08/Content/MOTU/PR/Digital-Performer-6.html
    [quote]XML file interchange with Final Cut Pro
    Both Digital Performer and Final Cut Pro™ (FCP) offer complete end-to-end production workflow: Final Cut for picture and DP for complete soundtracks including music, dialog, foley and sound effects. While recent advances in DP have made it the undisputed leader in film scoring features, DP6's new Final Cut Pro XML file interchange features could very well revolutionize the way film scoring and soundtrack production is done. The two most pressing challenges for any soundtrack producer are tight deadlines and last-minute picture edits. DP6 now allows for a dynamic link between the FCP editor and the soundtrack producer working in DP6. This link can be easily managed remotely via emailed XML interchange files (which are very small) or via a dynamic link between DP6 and Final Cut running side by side on the same computer.
    Here's how it works. When picture edits are made in Final Cut, the FCP editor can export an XML file that describes all current edits, which the DP6 composer/editor can simply import to then compare and conform all music and audio tracks to the latest picture edits. All changes are displayed in DP6's new "Import Final Cut Pro XML" window, which provides a complete, detailed list of every new picture edit. Double-click any edit in the list, and DP6 scrolls to and highlights the location of the edit in the Sequence Editor time line. The highlight shows a blue border (old position) and red border (new position) for each picture edit. The DP6 composer/editor can then adjust their conductor track, audio data and/or MIDI data as necessary to conform to the new edit, "snapping" their edits to the vertical red line if necessary.
    If DP6 is running on the same computer as Final Cut Pro, the "Export Final Cut Pro XML" command sends all tracks (and all sequences) in the current DP project to the project currently open in Final Cut Pro (or any FCP file on disk, if desired), allowing easy transfer of all work done in DP6 into Final Cut at any point during the production process, from previewing dailies to final conform and export from Final Cut.
    In the pressure-cooker world of film and broadcast, soundtrack production most often happens late in the overall production cycle, and these time-saving features offer the possibility for a quantum leap forward in up-to-the-minute delivery of changes to music and sound for picture.[/quote]
    I guess it doesn't sound a sexy as how the demo man made it seem. Is this the same as Logic import/export of XML files?

Maybe you are looking for