UpdateXML : How to update EmployeeName tag based on EmployeeID value

Hi All,
My XMLType (EMP_DOCUMENT) field in a table stores the following simple XML structure:
<DEPARTMENT>
     <DEPARTMENT_ID>1</DEPARTMENT_ID>
     <DEPARTMENT_NAME>Finance</DEPARTMENT_NAME>
     <EMPLOYEE>
          <EMPLOYEE_ID>1</EMPLOYEE_ID>
          <FIRST_NAME>ABC</FIRST_NAME>
          <EMAIL>ABC</EMAIL>
</EMPLOYEE>
     <EMPLOYEE>
          <EMPLOYEE_ID>2</EMPLOYEE_ID>
          <FIRST_NAME>xyz</FIRST_NAME>
          <EMAIL>xyz</EMAIL>
</EMPLOYEE>
     <EMPLOYEE>
          <EMPLOYEE_ID>3</EMPLOYEE_ID>
          <FIRST_NAME>zzzz</FIRST_NAME>
          <EMAIL>zzz</EMAIL>
</EMPLOYEE>
     <EMPLOYEE>
          <EMPLOYEE_ID>4</EMPLOYEE_ID>
          <FIRST_NAME>yyyy</FIRST_NAME>
          <EMAIL>yyyy</EMAIL>
</EMPLOYEE>
</DEPARTMENT>
Employee_ID is unique and Employee_Name is not unique.
I have a requirement to update the Employee_Name tag where i have the Employee_ID and the value to be updated.I tried the following but it updates all Employee_Names instead of updating the record i want:
UPDATE EMPLOYEE_DOCUMENTS p
SET p.EMP_DOCUMENT = updateXML(p.EMP_DOCUMENT,
               '/DEPARTMENT/EMPLOYEE/FIRST_NAME/text()',
          'Scott')
WHERE DOCUMENT_ID = 1
AND existsNode(p.EMP_DOCUMENT,'/DEPARTMENT/EMPLOYEE[EMPLOYEE_ID = 2')=1
I can see that updateXML essentially acts as 'ReplaceXML' where one tag can be searched and replaced with the new value.But is it possible to UPDATE a tag based on other tag at the same level (like update the employee_name based on employee_id)
Thanks,
Srihari
Edited by: srihari manian on Jul 15, 2009 7:19 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

I believe this is what you are looking for
WITH employee_documents AS
(SELECT XMLTYPE('<DEPARTMENT>
<DEPARTMENT_ID>1</DEPARTMENT_ID>
<DEPARTMENT_NAME>Finance</DEPARTMENT_NAME>
<EMPLOYEE>
<EMPLOYEE_ID>1</EMPLOYEE_ID>
<FIRST_NAME>ABC</FIRST_NAME>
<EMAIL>ABC</EMAIL>
</EMPLOYEE>
<EMPLOYEE>
<EMPLOYEE_ID>2</EMPLOYEE_ID>
<FIRST_NAME>xyz</FIRST_NAME>
<EMAIL>xyz</EMAIL>
</EMPLOYEE>
<EMPLOYEE>
<EMPLOYEE_ID>3</EMPLOYEE_ID>
<FIRST_NAME>zzzz</FIRST_NAME>
<EMAIL>zzz</EMAIL>
</EMPLOYEE>
<EMPLOYEE>
<EMPLOYEE_ID>4</EMPLOYEE_ID>
<FIRST_NAME>yyyy</FIRST_NAME>
<EMAIL>yyyy</EMAIL>
</EMPLOYEE>
</DEPARTMENT>') emp_document
  FROM DUAL
SELECT updateXML(p.EMP_DOCUMENT,
'/DEPARTMENT/EMPLOYEE[EMPLOYEE_ID = 2]/FIRST_NAME/text()',
'Scott')
  FROM employee_documents pwhich just updates the name for employee id 2.

Similar Messages

  • Script to to update users attribute based on EmployeeID Value from CSV file

    Hello, 
    i am trying to build script that read the data from CSV file, the only data exist on this file is the EmployeeID.
    so i need to read the EmployeeID and for each employeeID exist in this sheet in need to disable that user and  change the Description to "Disabled based on the HR Request"
    below script is not working for me any help plz 
    $path = "D:\Private\sample-data.csv"
    $LIST=IMPORT-CSV $path
    $UseremployeeID = $USER.employeeID
    FOREACH ($Person in $LIST) {
    $UserID = Get-ADUser -Filter {employeeID -eq ($LIST.Row[1])}
    foreach ($USER in $UserID){
    Set-ADUser -Identity $User -Description "Disabled based on the HR Request" -Enabled $false

    I managed to know the reason
    you should add -properties EmployeeID  to your code
    <snip>
    Hi,
    That's not necessary. The filtering is done serverside, so you don't need to request that it be returned.
    Example:
    Get-ADUser -Filter "Title -eq 'Some Title In Your Company'"
    Title isn't a default property, but the command above works just fine.
    Don't retire TechNet! -
    (Don't give up yet - 12,575+ strong and growing)

  • Update a table based on Min value of a column of a Another Table.Pls Help.

    Dear All,
    Wishes,
    Actually I need update statement some thing like below scenario...
    Data in table is like below:
    I wrote a query to fetch data like below ( actually scenario is each control number can have single or multiple PO under it ) (i used rank by to find parent to tree like show of data)
    Table: T20
    Control_no        P_no  Col3
    19950021     726473     00
    19950036      731016     00
    19950072     731990     00
                     731990 01
    19950353     734732     00
                     734732 01
    19950406     736189     00
                 736588     01
                 736588     02
                 736588     03                
    Table : T30
    Control_no      P_no              col3
    19950021     726473 
    19950036     731016
    19950072     731990     
                 731990     
    19950353     734732     
                  734732     
    19950406     736189     
                  736588     
                  736588     
                   736588     
      Now requirement is I need to update Table T30's col3 (which do have values in T20 but not this table) in such a way that , It should take MIN (COL3) from T20 and then update that value to related Col3)
    Better I can explain through below new data format in T30 after update:
    After update it should like:
    Table : T30
    Control_no       P_no    col3 (this is updated column)
    19950021     726473   00  -- as this is min value for Pno 726473 belongs to Control NO 199950021 in Table T20 above
    19950036     731016   00  -- as this is min value for Pno 726473 belongs to Control NO 199950021 in Table T20 above
    19950072     731990   00  -- see here..both Pno should updated as '00' as MIN value col3 in Table T20 related to this
                 731990      00     record is '00'  (out of 00,01 it should select 00 and update that value here)
    19950353     734732      00  -- same again both Pno should updated as '00' as MIN value col3 in TableT20 related to this
                 734732      00     record is '00'  (out of 00,01 it should select 00 and update that value here)
    19950406     736189      00  -- As there is single col3 value in T20, 00 should be updated here.
                 736588      01  --  Here it should update col3 as '01' since for this pno(736588)
                 736588      01  --  Here too it should update col3 as 01 per requirement ,minimum value of this pno in T20
                 736588      01  --     same here too.. Sorry if my post formatting is not good...
    Hope i am clear in my requirement..(update T30 col3 based on min value of col3 of related records)
    Please suggest some update sql for this...(ideas would be great)
    I am using oracle 10 g version soon will be migrated to 11g..
    Regards
    Prasanth
    Edited by: Onenessboy on Oct 20, 2010 12:13 PM
    Edited by: Onenessboy on Oct 20, 2010 12:15 PM

    Onenessboy wrote:
    I am really sorry, my post so nonsense in look..
    I used to use for actuall code..
    the out put i tryped, i used [pre] , [/pre] but still does not look good..
    hmm..thanks for your suggestion hoek..
    so any ideas about my requirement...I would suggest spending a bit more time trying hoek's suggestion regarding {noformat}{noformat} tags instead of repeatedly asking for more help.
    Because to understand your requirement, people are going to have to read it first.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to select different Querys based on Variable Value

    Hi guys i need to know how to select different Querys, based on variable values selected by the user, i try to do it using a Web Template but i don´t know how to program a Dynamic Query.....
    I hope sombody could help me with this
    Message was edited by: Oscar Diaz

    Hi Diaz,
    Can you explain the exact scenario which you are looking for!!!
    regards
    Happy Tony

  • How to Update in InDesign based on New XMLElements

    Hi Pals,
    I have InDesign File consist of contents which is based on an XML Hierarchy. And i have a new XML which is having some new XMLElements inserted in the Existing Hierarchy. The new added Elemensts are having same tag name.
    eg:
    InDesign Document XML Structure
    Root
    -<document>
      -<head>
      -<body>
      -<text1>
      -<text2>
      -<text3>
    New XML Structure
    Root
    -<document>
      -<head>
      -<body>
      -<text1>
      -<New>
      -<text2>
      -<New>
      -<text3>
    How to update the new elements in existing InDesign document in Exact place? Expecting favorable reply. Thanks in Advance.
    Regards,
    Subha

    i created below function but it did not update values properly
    Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
    $webURL = "http://tspmcwfe:91" $listName = "Courts"
    Get the SPWeb object and save it to a variable
    $web = Get-SPWeb $webURL
    $list = $web.Lists[$listName] $items = $list.items
    $internal_counter = 1 $flagPID =1 $vPID=0
    Go through all items
    foreach($item in $items)
    $vPID=0
    $PID = $item["ParentID"] -not $null $Pno = $item["Processno"] -match $null $between = $item["ParentID"] -match $vPID
    if($PID -eq $true -and $Pno -eq $true)
    if($between -eq $true) {
    $item["ProcessNo"] = $internal_counter $vPID=$item["ParentID"] } else { $item["ProcessNo"] = $internal_counter
    $vPID=$item["ParentID"] }
    $internal_counter++
    $item.Update()
    $web.Dispose()
    adil

  • How to update one table based on another table ??

    Hello Friends:
    I am trying to run the following query in oracle but it won't run.
    UPDATE BOYS
    SET
    BOYS.AGE = GIRLS.AGE
    FROM GIRLS
    WHERE
    BOYS.FIRSTNAME = GIRLS.FIRSTNAME AND
    BOYS.LASTNAME = GIRLS.LASTNAME;
    This query runs fine in sql server but in oracle its saying can't find "SET". PLease tell me what is the correct syntax in oracle to update one table based on another table.
    thanks

    See if this helps.
    If you wrote an SQL statement:
    update boys set age = 10;
    Every row in the boys table will get updated with an age of 10. But if you wrote:
    update boys set age = 10
    where firstname = 'Joe';
    Then only the rows where the firstname is Joe would be updated with an age of 10.
    Now replace the 10 in the above statements with (select g.age from girls g where g.firstname = b.firstname and g.lastname = b.lastname) and replace where firstname = 'Joe' in the second statement with where exists (select null from girls g where g.firstname = b.firstname and g.lastname = b.lastname). The same concepts apply whether 10 is an actual value or a query and whether you have a where clause with the update statement to limit rows being updated.
    About the select null question regarding the outer where clause:
    Since the query is checking to see if the row in the girls table exists in the boys table what the column is in this select statement doesn't matter, this column isn't being used anywhere. In this case Todd chose to use null. He could have also used a column name from the table or a lot of times you'll see the literal value 1 used here.

  • How to capture the entries based on filter values in oo alv..

    Hi all,
    I have a scenario in my oo alv report, when the user select the any column on report and selects the filter option. In that the user can enters required values. Based on filter values the output will be displayed. Now how can i capture currently displaying entries on report.
    Thanks,
    Ashok

    Hi Jozef,
    Is that GET_FILTERED_ENTRIES( ) reads the indexes or values from the entries..?
    Thanks,
    Ashok

  • How to create folder names based on Excel values or Txt files?

    Hi there,
    I often need to create large numbers of folders based on names I have saved in an Excel spreadsheet. I know in windows there is a way to create a macro within excel that automatically generates folder names based on cell values.
    I was therefore wondering how to do the same on a Mac operating system. The main thing is to find a way to automate the process. I understand this may involve copying the values to a text file.
    Below is an example of the names I need to create folders for (copied from the excel spreadsheet):
    Wash Bowl Small 600
    Deck Mounted Wash Bowl 500
    Wash Basin - 866 - 2 Shelves
    Wash Bowl Large 800
    Built-In Wash Basin With 1-Taphole
    Deck Mounted Wash Bowl 625
    Would really appreciate a simple step by step approach to an explanation. As my understanding of using Automator, Apple Script, Terminal, etc, is extremely basic.
    Thanks and Best Wishes,
    Graham

    Hi Niel,
    Thanks again for another superb response. I have another question. Is it possible to automatically generate sub-folders along with the folder.
    For example:
    Folder                                                Subfolder
    Wash Bowl Small 600          >            2D CAD
                                                               3D CAD
                                                               BIM
                                                               Images
                                                               Brochures
                                                               Specifications
                                                               Technical
                                                               Case Studies
                                                               Operations
    Deck Mounted Wash Bowl 500    >   2D CAD
                                                              3D CAD
                                                              BIM
                                                              Images
                                                              Brochures
                                                              Specifications
                                                              Technical
                                                              Case Studies
                                                              Operations
    Above shows the 9 generic sub-folders I need to create within each folder that is generated.
    Best Wishes,
    Graham

  • How to create xml nodes based on a value

    Dear friends,
    I've a question about graphical mapping in SAP PI...
    How can I create XML nodes on the target side based on a value in a XML field on the source side.
    For example:
    This XML field on the source:
    <NO_OF_LINES>4</NO_OF_LINES>
    Must result on 4 Lines on the Target:
    <LINE></LINES>
    <LINE></LINES>
    <LINE></LINES>
    <LINE></LINES>
    So it's actually the opposite of the Count function...
    I appreciate your help,
    Thank you in Advance,
    Kind regards,
    John

    Hi ,
    Try this
    NO_OF_LINES---> count---> UDF---> LINE
    example :
    UDF Code :
    for (int i=0;i<var1[0];i++)
    result.addValue("");

  • How to update xml content based on resource_view path?

    I am using resource db to store xml documents. I can ftp xml documents into a specific path within resource db. I have a xml schema registered and setup with a xml table. I would like to update a xml document based on a specific resource_view path.
    For example:
    /some/path/mydocument.xml
    I would like to upddate this document using the path "/some/path/mydocument.xml"
    How can this be done using SQL?

    Typically the best way is if you know the name of the default table that contains your document. You do the update on the default table as follows
    update yourTable  t
         set object_value = updateXML(...)
    where ref(t) = (
                     select extractValue(res,'/Resource/XMLRef')
                       from resource_view
                      where equals_path(res,'/some/path/mydocument.xml') = 1
                          )

  • How to update the price based upon PGI date

    Hi
            I have issue of updation of the Prices and freight based on PGI date in the billing we are using the two billing types for the excsies and tax invoice creation .And in the copy control pricing type is maintained Aas "C" for the billing types with single delivery but someHow MRP in the excise billing has been picked from the condition record thats validity is ended and in Tax invoice it picks up the correct prices
    Both pricing condition types has pricing type "B" from Billing date and in the freight we have maintained as "A" SRD
    But for the some cases specially for the excise related part that is based upon the MRP we are facing this issue
    Pricing date is some how coming from sales document
    Please find the problem details in the attachment

    Hi,
    if you see two condition tabs snap shots you can understand clearly because that two invoices has been created in two different dates and you have maintained the pricing date C-billing date ( KOMK-FKDAT).Due to this,the price of ZMRP is coming differently.After you creation of first invoice then you would have changed ZMRP amount.Now while you are creating second invoice ,system has taken new price of ZMRP in billing level.
    Note:While creating second invoice, PGI date might have come into billing level but someone would be changed billing date manually at header level of billing document.Please check that one also.
    Kindly let me know if you need further help on this.
    Thanks,
    Naren

  • How to update vendor address based on vendor control data

    Hello,
    i have a request to update one field (Search term 2) from Vendor master Address view:
    based on industry code populated for the supplier (LFA1-BRSCH):
    This means if industry code is populated, address field SORT2 must be updated with corresponding wording for this code.
    How is it possible to do this?
    I cannot use BAdI definition name ADDRESS_UPDATE as ADDRESS1_SAVED method is triggered only if one address field is modified.
    I found VENDOR_ADD_DATA enhancement spot with VENDOR_ADD_DATA BAdI definition: can i use SAVE_DATA method?
    If yes, which function module can i use to update LFA1 table? Is it OK with CHANGEDOCUMENT_SINGLE_CASE?
    Thank you for your help.
    Regards.
    Laurent.

    Hello Sreejith,
    thank you for the user-exit you gave me: it works as required.
    Here is ABAP code:
    CONSTANTS: lc_abap_true TYPE xfeld VALUE 'X',
               lc_lfa1      TYPE ad_ownertp VALUE 'LFA1'.
    DATA: lt_id_list TYPE TABLE OF bupa_partner,
          lt_lfa1    TYPE TABLE OF lfa1,
          lt_adrc    TYPE TABLE OF adrc,
          ls_lfa1    TYPE lfa1,
          ls_adrc    TYPE adrc,
          ls_address_selection TYPE addr1_sel,
          ls_addr1_val TYPE addr1_val,
          ls_addr    TYPE bapiad1vl,
          lt_addr    TYPE TABLE OF bapiad1vl,
          ls_addrx   TYPE bapiad1vlx,
          lt_addrx   TYPE TABLE OF bapiad1vlx,
          lt_return  TYPE isi_bapiret2_tt.
    DATA: lv_brsch_txt TYPE text1_016t,
          lv_objid TYPE ad_objkey.
    APPEND i_lfa1-lifnr TO lt_id_list.
    CALL FUNCTION 'BBP_VENDOR_GET_DATA2'
      EXPORTING
        wo_purch_org = lc_abap_true
      TABLES
        itab_id_list = lt_id_list
        itab_lfa1    = lt_lfa1
        itab_adrc    = lt_adrc.
    READ TABLE lt_lfa1 INTO ls_lfa1 INDEX 1.
    READ TABLE lt_adrc INTO ls_adrc INDEX 1.
    MOVE ls_adrc-addrnumber TO ls_address_selection-addrnumber.
    CALL FUNCTION 'ADDR_GET'
      EXPORTING
        address_selection = ls_address_selection
      IMPORTING
        address_value     = ls_addr1_val
      EXCEPTIONS
        parameter_error   = 01
        address_not_exist = 02
        version_not_exist = 03
        internal_error    = 04
        OTHERS            = 99.
    IF sy-subrc EQ 0.
      IF NOT i_lfa1-brsch IS INITIAL OR NOT ls_lfa1-brsch IS INITIAL.
        SELECT SINGLE brtxt
         INTO lv_brsch_txt
         FROM t016t
         WHERE spras = sy-langu
         AND   brsch = i_lfa1-brsch.
        IF ( ls_lfa1-brsch NE i_lfa1-brsch OR ls_adrc-sort2 NE ls_addr1_val-sort2 ).
          CLEAR : lv_objid.
          MOVE i_lfa1-lifnr TO lv_objid.
          MOVE lv_brsch_txt TO ls_addr-sort2.
          APPEND ls_addr TO lt_addr.
          MOVE 'X' TO ls_addrx-sort2.
          APPEND ls_addrx TO lt_addrx.
          CALL FUNCTION 'BAPI_ADDRESSORG_CHANGE'
            EXPORTING
              obj_type    = lc_lfa1
              obj_id      = lv_objid
            TABLES
              bapiad1vl   = lt_addr
              bapiad1vl_x = lt_addrx
              return      = lt_return.
        ENDIF.
      ENDIF.
    ENDIF.    "sy-subrc
    Regards.
    Laurent.

  • How to update the log based on verifyAttributes status

    Hi All
    I am new to OTS and i am using 12.2 version. Here is the question..
    I am writing some info like PASSED/FAILED in log based on my assertion.This can be achieved in two ways.
    1.Using exists() method ,if the object is present then we can update the log as "passed" similarly if object does not exist then we log it as :"Failed"
    If i user verifyattribute method and i want update the log as "Passed" of verifyattribute is passed and vice verssa(ie update the log as :"failed:" if verifyattribute is failed)
    from help doc i have seen that this method verifyattribute/ verifiyattributes returns void.
    Any ways to handle this.. let me know
    Thanks inadvance
    Edited by: 1000235 on Apr 22, 2013 3:27 AM

    Hi,
    You'll have to work with exists() if you have to custom print your own log as assert/verify are void methods. If custom log isn't necessary I would suggest you to use Object test in Openscript it logs pass/fail of objects tests you create in results page. To create user object tests click on the Add Object Test > Give a name to test > select the element you want to test > select the attribute you want to verify > Save Test.

  • How to update the record based on checkbox

    Dear All,
    Good Afternoon,
    Here i am creating Company Creation Page,
    Company has multiple personss
    At the time of company creation we set one person as primary person.
    that means we just pass that person id as company primary person id columnnn in company table.
    vo.getCurrentRow().setAttribute("CompPrimarypersonid", pid);
    here i am getting so many persons details with checkboxes.
    suppose i want to set another person as a primary person by just clicking on check box.
    At that time pass this person id into company primary persin id column in company table.
    already primary person id is overwrite with this company id.
    how can we get this requirement.
    its very urgent to mee
    give me the guidance for this requirement.

    Hi,
    You can write a procedure and call it through AM using Callable Statement passing the person_id and company_id.
    Now in the procedure, you can check that what is the primary person_id of this company_id.
    Store that primary_person_id in a variable say test.
    then update the company table with new primary person_id
    update company set primary_person_id = <new person_id > where primary_person_id = test;
    commit;
    Thanks,
    Gaurav

  • How to update one lov based on value selected from another lov.

    Hi ,
    I have a form in which I created the 2 LOVs for my event_date field and event_name field each which is stored in one table.
    t I want to update the event_date LOV everytime event_name is selected.
    How can I achieve this.
    Thanks.
    Neeti.

    Hi,
    You can do this using dynamic LOVs. Here are the steps for populating a employee LOV on selecting a department.
    1) Create a dynamic lov say emloyee_lov with a bind variable like this
    select empno,ename from scott.emp
    where deptno = :dept
    2) Create a form on scott.emp.
    3) In the empno field which should be a LOV type of field, associate it with
    the above employee LOV.
    4) Then set the binding(s) for the bind variable(s) defined in the lov by
    selecting the deptno column.
    This would help.
    Thanks,
    Sharmila

Maybe you are looking for

  • Restrict Withholding Tax change in not cleared documents

    Hello, We want to adjust the Document chnage rules - OB32 in a manner that it restricts Withholding Tax fields from changing when the document is not cleared. We tested & found that the Withholding tax fields as below when defined in document change

  • Alternate base for ED calculation in PO

    Dear All, Kindly guide on below isse. Suppose I have to Procure material A @ Rs. 100 then its PBXX / PB00 value will be Rs.100 and system will pick this value as Base for Excise calculation however there is a discount of 25% leading the price of the

  • OBIEE 11g Repository Question: session context

    The Metadata Repository Builder's Guide says in chapter 13, "Note: Alternatively, you can use the database session context to pass end user identity to the database. Use a connection pool script to set up session context. Note that this approach does

  • I cant see canon 5d mark III raw preview on finder -

    I tried Apple Camera Raw 3.12 but it just close after showing a pop up window the uppgrade is only for Aperture and Iphoto - I even installed Adobe camera Raw 7, and nothing.

  • MacBookPro 15" CPU whine: how to test,  samples as .mp3

    My W8614- MacBook Pro 15" still has the CPU whine, both with the power adapter plugged in (lower volume) and unplugged (higher volume). It emanates from both speakers even when the speakers are muted (volume zero). My guess for the root cause is not