PL-SQL mass update help.

I want to do a mass update with PL-SQL on a table with different values using one SQL QUERY.
Here is the table and some sample records
USER_TABLE
USER_ID | ACCOUNT_ID | ROLE | CREATED_TIMESTAMP |
101 | 999 | ADM | 01/20/2009
102 | 999 | SUB | 01/20/2009
103 | 888 | ADM | 01/20/2009
104 | 888 | SUB | 01/20/2009
SERVICE_TABLE
USER_ID | ACCOUNT_ID | .... | .... |
0 | 999 |
102 | 999 |
0 | 888 |
104 | 888 |
I want to populate SERVICE_TABLE where USER_ID=0.
USER_ID=0 in the SERVICE_TABLE for all User’s whose ROLE = ‘ADM’
For example in the SERVICE_TABLE,
where ACCOUNT_ID =999 and USER_ID = 0,
USER_ID should become 101
where ACCOUNT_ID =888 and USER_ID = 0,
USER_ID should become 103
Can someone please get me started, I am new to PL-SQL.

Ok,
That minds that you have more than one admin with de same account_ID (The scenario that I mencioned before).
This query will let you know wich ones are duplicated
select u.account_id, count(*)
from user_table u
where u.role = 'ADM'
group by u.account_id
having count(*) > 1;
select *
from user_table u1
where u1.account_id in
(select u.account_id
from user_table u
where u.role = 'ADM'
group by u.account_id
having count(*) > 1)
and u1.role = 'ADM';
could you post the results?
Regards,
Mike

Similar Messages

  • Mass update

    Hi All,
    have two important questions:
    In TopLink, is there an efficient way to do an UPDATE statement for say 10,000 rows, and still not use a stored procedure? Something like "update all instruments for this organization to rating AAA," but without the overhead of looping through a collection of instruments.
    In TopLink, how do we insert a row and initialize it to a current database timestamp? Not Java timestamp, but database. Something like "INSERT INTO table (modified) VALUES (CURRENT TIMESTAMP)"?
    Please help!

    In the 10g (9.0.4) version mass updates are only supported through custom SQL. We are adding support for these through the TopLink query and expression framework for 10g (10.0.3). This UpdateAllQuery will optimize these sorts of operations while still ensuring cached instances are properly updated or invalidated.
    Again, the upcoming 10.0.3 release will support the returning clause that will allow these values to be set in triggers and returned to Toplink and the application in the result of the INSERT. Currently this can only be accomplished using a stored procedure.
    Doug

  • Mass update of a custom field at Product Revenue level

    We are trying to update a custom field at Product Revenue level using the Opportunity Web Service. The webservice call is timing out as we have thousands of Opportunities.
    I would appreciate if anybody gives input on how we can massively update a custom field using Opportunity Web Service.
    OR
    Is there a way to mass update a custom field at Product Revenue level other than using a web service.
    Thanks for your help!
    -purna

    If you are not very much obsessed with Webservices, the other workaround is the Data Loader Tool. It was discussed earlier in this forum.
    Pl refer-
    Re: Product Revebue Updation
    Hope this helps.
    Rgds,
    Amit Sahu

  • How to get changes of a custom PL/SQL package updated in ISG?

    Hi All,
    I need some help on how to change a custom PL/SQL package in ISG integration repository:
    I already uploaded my custom PL/SQL package to the integration repositoy some time ago. Now I have made some changes to PL/SQL record/table types defined in the package (added some fields and removed some others). These changed record/table types are used by a procedure I already uploaded to the integration repository. When regenerating the WSDL for my PL/SQL package in integration repository I get an error that the wrapper for respective procedure can't be found. When checking up the SQL types that were automatically generated (by JPublisher) for corresponding PL/SQL types, these generated SQL types are invalid...
    So it seems that in one case JPublisher generated an empty SQL type (with no attributes). In another case JPublisher generated the SQL type with old attribute list, so it didn't adopt the changes of corresponding PL/SQL type in the package...
    Can anybody tell me how to get the changes of a cusotm PL/SQL package updated in ISG? Or is there any possibility to first remove a whole PL/SQL package from the ISG integration repository (and getting rid of all old automatically generated SQL types), so that I can newly upload my PL/SQL package afterwards?
    Thanks
    Konrad
    Edited by: Konrad on 24.10.2011 10:51

    Thanks Daniel, for your reply...
    (-> for info: I'm a colleague of Konrad...)
    Yes, we used a higher version number - and the upload of iLDT file works fine...
    But, the problem occured when generating the WSDL...
    However, I think we have found an approach of how to get the changes of a custom PL/SQL package updated correctly in ISG:
    1. Save a copy of PL/SQL package and then delete it in the database
    2. Regenerate the WSDL for PL/SQL package in ISG (seems that all atutomatically generated JPub wrappers and SQL types are also deleted)
    3. Restart all processes
    4. Create the changed version of PL/SQL package in the database again
    5. upload of iLDT
    6. Regenerate the WSDL for PL/SQL package in ISG
    Best Regards
    Carolin

  • Material Account Assignment Group, in Sales Order Mass Update

    Sd Experts,
    We just went live, our consultant updated Account assignment group at the material level but did not updated existing materials. When we caught the problem and updated exisisting materials there were some existing orders already created. Which now I am getting an account determination error due to this field being empty at the material level.
    We have some sales orders that I need to update but they are just too many, currently I have been fixing them thru VF02, for to the material and update manually.
    Does anyone has any idea how to mass update this field for all existing orders, to update "Account Assignment Group" field automatically
    Your help will be greatly appreciated.

    Hi
    In Mass transaction choose object type as #BUS2032,after executing in the next screen from the tables choose#Sales Order Item Data, and from the fields choose#AcctAssgGr (MASSSDHE)-MASSSDHEAD_S-KTGRD, now execute to find fields Sales document and Sales Document item , here load all the Sales Orders for which the change is needed along with the items for which the changes are needed execute again to find the next screen with Sales Documet, Sales Document item and Account assignment which needed to be changed,now select the entire block enter new values in the Account assignment  box in the above, click on the 'Carry out MAss change button ' and then save, it will take some time basing the change tobe carried and issues a log as to how many documents were changed
    Hope this is clear,please do a test run before.
    Regards
    Chandra

  • Mass Updating of Selected Rows

    (As you can see from my low number of posts I'm new to ApEx, so any information you can provide is appreciated.)
    Hi,
    I've been asked to include what I consider a heavy duty feature on a report. It has been requested that there is a form region above a report region. The form will have some fields on it to be used to mass update selected rows.
    For instance, let's say the report is a list of employees and their dept and the form has a dropdown dept field that contains a list of depts. They want to be able to select certain employees on the report, then select a dept from the form and then click an Update Rows button. They want the selected rows to be updated with the selected dept. * Also, they don't want the report to be editable. * The only way to update any rows is thru the Update Row button.
    I'm new to ApEx and can code in JavaScript, but am not an expert in either. And, I'm still trying to figure out what JavaScript syntax works in Element Attributes, etc. fields. But, I digress.
    I have looked over several threads, and went to several demo pages, and have learned some things. Hopefully they are correct. If not, please correct me.
    - Using the Row Selector is tricky.
    - You can get the Row Selector on a regular SQL report by changing it to Updateable SQL, adding the Row Selector type, and changing it back.
    - You can only see row information on a column if the column is editable.
    I now have a report that is NOT editable and has NO editable columns. And the report has the Row Selector. Also, the ID (key) of each row is the first column of each row. (It's a link field that populates another page.) With the ID I can populate the correct record. I'm thinking I need to populate the ID again in another column into a text field and then be able to access that value on the selected rows.
    Here's my dilemma. (That is, if I'm on the right track.) I need to know which rows are selected and then access the ID (key value) of that row. After that I can let my PL/SQL do the work.
    - - 1. How does the 2nd ID need to be defined such that people can't edit it, but the value can be retrieved? And, how is this done? I assume something can be put in the Element Attributes. If so, will you please provide the code?
    - - 2. What is the trick to knowing which rows are selected? An example snippet of code would be great here too.
    - - 3. Also, tell me if I'm on the wrong track and need to provide a solution in a different way.
    Sorry for the novel, but I wanted you to have a good idea of what I'm trying to accomplish so you may provide appropriate answers.
    Thanks much, Tony

    Hi Tony,
    check out the following threads:
    Re: Reference a value within a report????
    Re: MRU - trying to restrict UPDATE to only certain users - everyone INSERT
    BTW, you don't have to use any JavaScript. When you write your "Update pl/sql process" for the tabular form, just reference you page item which contains the department for your mass update.
    eg.
    FOR ii IN 1 .. Apex_Application.g_f01.COUNT
    LOOP
        UPDATE EMPLOYEES
          SET DEPARTMENT_ID = :P4_NEW_DEPARTMENT_ID
        WHERE EMPLOYEE_ID   = Apex_Application.g_f02(Apex_Application.g_f01(ii))
    END LOOP;Hope that gives you a direction how to solve that
    Patrick
    Check out my APEX-blog: http://inside-apex.blogspot.com
    Check out the ApexLib Framework: http://apexlib.sourceforge.net

  • Mass updating a multi-valued field- to append the new value

    I have a question on multi-valued fields:
    I have store table with 5 multi-valued fields, say MLB, soccer, college FTBL, college Basketball, etc. 
    A store can have 4 MLBs, 2 soccer teams, and so on. 
    Say, there is a new MLB that came out called Mexico MLB team. 
    A user wanted to add this to 30 stores using a mass update.  But remember the 30 stores can have totally different sets of values in the multi-valued fields.
    How can I add this new value while still preserving the MLB team’s values of each store record?
    Does MDM not support this feature?
    I am using SAP MDM SP6
    An answer would be highly appreciated.
    Thanks
    Savi

    Savi,
    I assume you are defined these fields as multi-value lookup and linked to main table. In general, you can not because it will mess up and overwrite your multi-value entries for all of your 30 store records.
    Here is something in MDM come in handy. It is following the same concept but design your model a little differently. If you model your multi-value fields into qualified lookup table, it will be easier and optimized to handle.
    You can select all 30 records and mass-update with adding the new MLB entry into your Q-lookup table. Once you save, this mass-update action will respect all your diversity of each individual records with the new value added.
    Hope this helps
    If this answers your question, please kindly reward the points.
    Regards
    Dawei

  • Mass Update of Business Partner Data in CRM

    Hi,
    I would like to know how I can perform a mass update of business partner data in CRM and then have this replicated into R/3.
    I have found notes 802804, 876602, 859632 but these only apply to CRM 5.0 and we are currently working on CRM 4.0.  Does anyone know of anything similar which exists in CRM 4.0?
    I have checked other posts and found help files links like the one below but is this only on CRM 5.0?  (http://help.sap.com/saphelp_crm50/helpdata/en/3c/9b56fae6c7424cafcdf17370399812/frameset.htm )
    Has anyone used the tx. MASS in CRM?
    Also our volume update levels is as high as 300,000 record and updating in CRM and replicating into R/3 through the middleware is causing performance problems.
    Does anyone have any tips on the best approach for this?  Many thanks.
    Regards
    JoJo

    Mass not available in 4.0, could write your own LSMW routine but you still will create bdocs for updates so not sure how that will improve your performance.

  • SQL to update two columns in TABLE2 from TABLE1

    I know this is a simple question for some of you, but I am new to SQLs, so please help...
    I have two tables TABLE1 & TABLE2 as below, both tables contains more then 50million records:
    SELECT * FROM TABLE1.
    ID                        BUS_FID                WORKID                  STATIONID                 
    28400000117234         245                    13461428.25           16520877.8            
    28400000117513         403                    13461428.25           16520877.8            
    28400000117533         423                    13461428.25           16520877.8            
    28400000117578         468                    13461428.25           16520877.8            
    28400000117582         472                    13461428.25           16520877.8            
    SELECT * FROM TABLE2.
    BUS_FID                    ID                 TRPELID                RELPOS                 WORKID                 STATIONID               
    114                    28400000117658         28400000035396         23.225                                                              
    115                    28400000117659         28400000035396         23.225                                                              
    116                    28400000117660         28400000035396         23.225                                                              
    117                    28400000117661         28400000035396         23.225                                                              
    118                    28400000117662         28400000035396         23.225                                                              
    119                    28400000117663         28400000035396         23.225                                                              
    120                    28400000117664         28400000035396         23.225                                                              
    121                    28400000117665         28400000035396         23.225                                                              
    122                    28400000117666         28400000035396         23.225                                                              
    123                    28400000117667         28400000035396         23.225                                                              
    124                    28400000117668         28400000035396         23.225                                                              
    125                    28400000117669         28400000035396         23.225                                                              
    126                    28400000117670         28400000035396         23.225    Now I tried to use following SQL to update WORKID & STATIONID columns in TABLE2 but failed. BUS_FID in both tables have been UNIQUE indexed and they can be used as primary keys to join these two tables.
    UPDATE (
      SELECT  p.WORKID px,
              p.STATIONID py,
              p.BUS_FID pid,
              temp.WORKID tempx,
              temp.STATIONID tempy,
              temp.BUS_FID tempid
        FROM  TABLE1 temp,
              TABLE2 p
        WHERE pid = tempid
      SET px = tempx,
          py = tempy;
    COMMIT;with above code, Oracle returned following errors:
    SQL Error: ORA-00904: "TEMPID": invalid identifier
    00904. 00000 -  "%s: invalid identifier"Can anyone help me to correct it? Thanks~~~
    BTW, both two tables contains over 50 million records. So, if you have a better SQL to perform the same task, please let me know!
    Appreciated your help at advance.

    Hi,
    984210 wrote:
    Tried to change to
    p.bus_fid = temp.bus_fidit start running.
    Can anyone please explain to me why this is happening? Thanks!!Column aliases (such as pid and tempid in your statement) can't be used in the same query in which they are defined (except in an ORDER BY clause). Elsewhere, you have to refer to the columns by their actual names.

  • Xi JDBC Adapter - Query SQL Statement & Update SQL Statement

    Hi!
    I configure the JDBC adapter sender (XI) to take data from Oracle database.
    I set the Query and Update SQL Statement in the Processing parameters of the communication channel in this way:
    Query SQL Statement :
    SELECT * FROM XI_TABLE WHERE STATUS = 'WAIT' ORDER BY ROW_NUM
    Update SQL Statement :
    UPDATE XI_TABLE SET STATUS = 'DONE', DATE = SYSDATE WHERE STATUS = 'WAIT'
    My question is :
    If a new record with the field STATUS = 'WAIT' is added to the table (xi_table) during the time between the execution of the query statement and the start of the update statement, what will happen to that record during the update?
    There is a way to avoid the update of that record? or to pass to the update statement only the record selected in the query statement?
    Please, may you give me some example?
    Thanks,
    Francesco

    hi,
    did you check "Isolation Level for Transaction"
    for the sender jdbc adapter?
    http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/content.htm
    Regards,
    michal

  • Mass update of email in the vendor master record

    Hello to you all,
    Does anyone know how can I run mass update of email in the vendor master record for a big No. of entities?
    XK99 won't help since you can't find the email,
    Batch input recording won't help as well since the email can't be found.
    I will appreciate your help,
    Amir

    Hello Amir,
    You can use LSMW for update operation. You should create a batch input recording for transaction FK02. But you must tick "Use central address management" checkbox on FK02 screen while recording batch input. After that you will see E-mail field on screen.
    Regards,
    Burak

  • LSMW Mass Update Vendor Master

    I have a request to use LSMW to read all vendor records and reformat and update the tax code (LFA1-STDC1) field. Does anyone know if this can be done with LSMW? I am not sure how to do it. Or, is it easier to develop an ABAP routine to do the updates?  Any help will be rewarded.

    For mass updation one can use LSMW Object: 0040 / 0001 / RFBIKR00 / B or else try using FM vendor_update .
    null

  • Execute SQL Task - UPDATE or Data Flow Data Conversion

    Good Morning folks,
    I want to know which is more fast to convert data type.
    I want to convert nvarchar(255) to datetime2,
    using t-sql (execute sql task)
    UPDATE TBL
    SET  FIELD1= CAST(FIELD1AS DATETIME2)
    GO
    or data conversion(data flow)
    Thank..

    Itz Shailesh, my t-sql have only UPDATE, not many UPDATES... so it's one batch, no 2,3,4... So.. it's Only one update.. ex: update table set field1 = cast(field1 as datetime2), field2 = cast(field2 as datetime2). not : update table set field = cast(field
    as datetime2) go    update table set field2 = cast(field2 as datetime2) go.... understand?
    Yeah, I understand that you have to update just 1 field. What I am saying, if you have to update millions of rows then you must update rows in batches ( lets say batch of 50k). This way you will only touch 50k rows at a time and not all rows from table.
    I see that your rows are less however I would still prefer the option of data conversion transformation over update statement.
    If this post answers your query, please click "Mark As Answer" or "Vote as Helpful".

  • Mass updating/uploading of a price list

    Hi,
    Need to know if there is a way to mass update a price list. For example, I have 1000 items on price list 3. I need to update the prices of all items in the list and there is no definete factor. Since there is no definete factor I need to update all manually and since there are many items, need to know if there is a way to upload the prices for a specific price list.
    also need to know if there is any way to update the "Last Purchase price" list
    thanks for any help !

    Hi,
    thanks for the details. I still have an issue on this. I have used the templates and tried to upload the price list and face the following problem.
    First, I am not clear as to what the field "LineNum" in the "Item_Prices" template means. I assumned that this was the price list number, but even though the upload says that all items were successfully updated, I cannot find any price list that has the updated prices... all lists still have the same old price... : (
    Now I am confused... Need some help on the below:
    1. LineNum : Is this the price list number ?
    2. I have manually maintained some of hte prices, can they be updated ?
    3. What about the prices that are taken as a factor of a base list ( like 1.3x Last purchase price...)
    Need some help urgently on this please...
    Thanks !
    Nirusha

  • Mass updation of Priority field in the process order header screen

    Hi Friends,
    Can any body knows on how to do mass update the Priority field in the process orders after release.(with out upload using BDC).
    or can we update the priority field in process order during mass release of process orders using  T- code: COHVPI?
    Is there any standard transaction? else please tell me the solution if there is any other way of doing this task.
    thanks&regards,
    Purna

    Purnachander,
    Your requirement can not be fullfilled with any standard transaction.
    BDC is best suitable option.
    Hope this helps you.
    SmanS

Maybe you are looking for

  • Issues with OS 10.0.4

    Hey Guys I am currently upgrading my 81year old mothers mac. she has a Imac 350MHZ slot loading w/128MB of memory, dual boot running classic OS 9.9.2 ond OS 10.0.4. my questions are: 1. Can i load 10.1, 10.2 or 10.3, and where can i reliably purchase

  • Installing windows 7 on hp pavilion g62228dx

    it  is possible to install windows 7 on my hp pavilion g62228dx??...... and get the drivers for it also.....because im not happy with windows 8.1 i await your imidiate relpy\............

  • 2008 to 2012 Express

    Hello. I currently have an application running on a server with SQL 2008 (Server 8.0.760). I am moving to a new application on a new server running SQL 2012 Express (11.0.2100). Can the tables be copied from sql 2008 and recreated in sql 2012? I don'

  • Universe Migration Procedure from TEST Server to PROD server

    Hi, We are using SAP BO XI R3 version in our project TEST windows 2003 server. we have designed the universe in TEST BO Server and it's working great. Now, we would like to move/migrate the universe created in TEST Server to the PROD server. please l

  • Which is the best version of Discoverer with Oracle 9iAS ?

    I have been told to find the best version of Oracle Discoverer for ORacle 9iAS - for the ORacle Financials and HR (E-Business suite ) ? Can anyone direct me to the manual where it explains the integration of ORacle Discoverer with E-Business suite ?