Need a Query to update....below are requirements

Hi,
I need a query to update table xx_cc_audit. below are requirements.
In xx_cc_audit I have more than 1000 rows. In this table Column - contract_number is inserted as null for some rows.
I need a query to update this xx_cc_audit table which will replace null contract numbers with correct ones.
In table xx_cc_audit I have column - instance_id which is not null and not unique.(duplicate instance id's can be there).
With this instance_id i can get the contract_number from other table okc_k_headers_b .
I need a query to update xx_cc_audit table.
Presently what I'm doing :
Select XS.instance_id
FROM cs_incidents_all_b CS,xx_cc_audit XS
where XS.contract_number is null
AND XS.SR_NUMBER = CS.incident_number
AND XS.ACTIVITY_TYPE = 'TROUBLESHOOTING';
Note : The above query can give duplicate instance_id.
Say, above query results in 100rows.
I will copy any 1 instance_id in a paper and then pass it to below query.
SELECT contract_number
FROM okc_k_headers_b
WHERE id = (SELECT MAX(dnz_chr_id)
FROM okc_k_items
WHERE object1_id1 = TO_CHAR(144849056) --instance_id
AND jtot_object1_code = 'OKX_CUSTPROD'
AND object1_id2 = '#'
AND chr_id IS NOT NULL);
I'll get contract_number.
then i'll update xx_cc_audit table as below.
update      xx_cc_audit set contract_number = 1223464789 -- which i got as a result of above query
where contract_number is null
and instance_id = 144849056     --this i copied from paper, as mentioned above     ;
this will update my table.
I have more than 1000rows, so i need a query which will update 1000rows in 1 shot.
Please help me.
Thanks!...
Edited by: Kiran Sanga on Jul 20, 2009 2:15 AM

OK, so that means a maximum of 10 distinct IDs in okc_k_headers_b can be matched with xx_cc_audit xca.
That's a data issue for yourself that you'll need to work out, i.e, are you being too restrictive in any of the subqueries, particularly this one:
WHERE id = (
    SELECT MAX(dnz_chr_id)
      FROM okc_k_items
    WHERE object1_id1 IN (
      Select XS.instance_id
      FROM cs_incidents_all_b CS,xx_cc_audit XS
      where XS.contract_number is null
        AND XS.SR_NUMBER = CS.incident_number
        AND XS.ACTIVITY_TYPE = 'TROUBLESHOOTING')
  AND jtot_object1_code = 'OKX_CUSTPROD'
  AND object1_id2 = '#'
  AND chr_id IS NOT NULL)Edited by: SeánMacGC on Jul 20, 2009 3:37 AM
And here is a slight different version of the update that should perform a little better:
update xx_cc_audit xca set contract_number = (
  SELECT contract_number
    FROM okc_k_headers_b okhb
WHERE id IN (
    SELECT dnz_chr_id
      FROM okc_k_items
    WHERE object1_id1 IN (
      Select XS.instance_id
      FROM cs_incidents_all_b CS,xx_cc_audit XS
      where XS.contract_number is null
        AND XS.SR_NUMBER = CS.incident_number
        AND XS.ACTIVITY_TYPE = 'TROUBLESHOOTING')
  AND jtot_object1_code = 'OKX_CUSTPROD'
  AND object1_id2 = '#'
  AND chr_id IS NOT NULL)
  AND xca.instance_id = okhb.object1_id1
where contract_number is null;

Similar Messages

  • Need a query to update the inventory item to non inventory item

    Dear all,
            I need a query which should update the Inventory to Non - Inventory Item.

    Hi,
    You need to freeze the inventory by click inactive tick box. This will prevent users to use the inventory.
    The inventory posting lists will still exists as an inventory's transaction history for auditor if the inventory have had transactions.
    To empty the warehouse, just perform good issue and use inventory decrease account. After the warehouse has been empty, create similar inventory item by right click --> select duplicate. Create new item code and in the tab remarks, just write this non inventory item was ever inventory item with code e.g. xxxx.
    if you want to recover the stock, just create new item and then receive the stock into warehouse using Good receipt. use the same account code with account code used in the good issue.
    JimM
    PS.
    Do not use sql statement to update B1 database. No SAP support provided afterwards.

  • Need you help to update business area for FI Document  generated  at migo

    HI guys
    I am looking for MIGO Badi or user-exit which will help update business area which is mandatory field but when movement type 101and the account assignment tab is not there when the movement type is 101 at the time of GR so i want to update it BA in for FI Document generate  in background so as to complete the GR. 
    Thanks

    Hi Niraj ,
    I Have check the badi but there is no structure of FI item data  generated for which i can insert the BA for the line item generated
    Thanks
    Regards
    Nilesh

  • Need ABAP code for the below Services requirement

    Hi,
    We have a requirement to show all the services for a particular Purchase order number.For this I built a view on 2 tables ESLL and EKPO.Now based on the below logic I need to bring the services for the Purchase order..
    1.Enter PO number,item no. and Doc category in EKPO and find the Pack no.
    2.Now take the Pack no. of EKPO and give in ESLL and find the Sub pack no.
    3.Now take this Subpack no. and Give this sub pack as Pack no. in ESLL
    4.This will be the Service entry record for that PO number.
    Can any one Please suggest me to how to write the ABAP code for the above logic.
    Thanks & Regards,
    Dinakar

    Hi Dinaker,
    Did you find any solution for this issue. I too have a similar requirement of pulling all the service orders for a specific Purchase Order in the BW report.
    Thanks,
    SAPBWI

  • Need a Query to update table from another table.

    I have two tables Table A and Table B , till now in table “A”. I have a column which consist of IDs and duplicate IDs( which are basically formed by Original Ids) , I have another table i.e. table “B” , which gives a mapping between original ids and duplicate Ids
    TABLE A:
    ID/DUPLICATEID      NAME
    1     Rahul
    1_CAD     Pawan
    2     Nikhil
    3     TOM
    3_CAD     Ravi
    3_MQ     Puneet
    TABLE B:
    ORIGINALID     DUPLICATEID
    1     1_CAD
    3     3_CAD
    3     3_MQ
    Now I want to have another column in Table “A” , which will give me the mapping between the original Id and duplicate Id as shown in updated table “A”.
    UPDATED TABLE A:
    ID/DUPLICATEID     NAME     ORIGINAL_ID
    1     Rahul     
    1_CAD     Pawan     
    2     Nikhil     
    3     TOM     
    3_CAD      Ravi     
    3_MQ     Puneet     
    Now I want to write a Query in which I can update this column (ORIGINAL_ID) of Table “A”, from the table B(basically want to update mulitple rows using single query), because table B already has this mapping. Can any one help me in this. I am basically a Java guy , so I don’t know much about it. I hope to get a positive response from you people, Thanks in advance!

    Here you go...
    <pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%">
    <code>
    SQL&gt; CREATE TABLE A (ID VARCHAR2(10), NAME VARCHAR2(10), NEW_ID VARCHAR2(10));
    Table created.
    SQL&gt; INSERT INTO A VALUES ('1', 'Rahul', '');
    1 row created.
    SQL&gt; INSERT INTO A VALUES ('1_CAD', 'Pawan', '');
    1 row created.
    SQL&gt; INSERT INTO A VALUES ('2', 'Nikhil', '');
    1 row created.
    SQL&gt; INSERT INTO A VALUES ('3', 'TOM', '');
    1 row created.
    SQL&gt; INSERT INTO A VALUES ('3_CAD', 'Ravi', '');
    1 row created.
    SQL&gt; INSERT INTO A VALUES ('3_MQ', 'Puneet', '');
    1 row created.
    SQL&gt; CREATE TABLE B (ID VARCHAR2(10), NAME VARCHAR2(10));
    Table created.
    SQL&gt; INSERT INTO B VALUES ('1', '1_CAD');
    1 row created.
    SQL&gt; INSERT INTO B VALUES ('3', '3_CAD');
    1 row created.
    SQL&gt; INSERT INTO B VALUES ('3', '3_MQ');
    1 row created.
    SQL&gt; COMMIT;
    Commit complete.
    SQL&gt; UPDATE A
    2 SET NEW_ID = NVL((SELECT B.ID FROM B WHERE A.ID = B.NAME),A.ID)
    3 /
    6 rows updated.
    SQL&gt; COMMIT;
    Commit complete.
    SQL&gt; SELECT * FROM A;
    ID NAME NEW_ID
    1 Rahul 1
    1_CAD Pawan 1
    2 Nikhil 2
    3 TOM 3
    3_CAD Ravi 3
    3_MQ Puneet 3
    6 rows selected.
    </code></pre>
    Note: While asking question do give us DML/DDL script. It will make peoples life better.
    Karthick.
    http://www.karthickarp.blogspot.com/

  • Need link for iCal updates (they are not showing on Software Update)

    Apple's iCal update page does not give an actual update - it just gives instructions on how to use OSX 'Software Update'. Software Update doesn't show any iCal updates when I run it.
    I need the latest versions for Panther 10.3.9 AND the version for Tiger 10.4.9
    So what is the bonafide link to getting iCal updates/versions?
    Anyone know? Thanks.

    mrchauncey,
    iCal 1.5.5 is the most recent for Panther, and can be downloaded from here.
    In order to obtain the most recent version for Tiger Mac OS X 10.4.9, you can use the Custom Install feature from your Mac OS X installation disk. Then use the Mac OS X 10.4.9 Combo Update to bring the iCal version up-to-date for that release of Tiger.
    ;~)

  • Query all applications that are connected to database in the current time

    Dears,
    I need to query all applications that are connected to database in the current time. I tried using v$session but i could not reach through it to the application that are logged now to database.
    As example, i connect to DB through Web Application and tried to search in v$session to can see Web Application session but i did not see it :(
    From searching in google, found that there is a package named "DBMS_APPLICATION_INFO". I expected that it can help me in my request but i could not use it.
    Please, advise me. Is this package help cover my requirements or there is another method ?
    Thanks & Best regards,

    sybrand_b,
    I think that i appreciated you once you replied me and what i wanted exactly from you "Provide me Link help me more for investigation" and you did not provide something.
    Where is the documentation that i could not read it !!!!!!
    FYI, you are not the only one that have information_
    Anyway ,as usual i will reply you in polite way.
    Thanks and i will not have more input here with you !!!
    Dear All,
    Sorry for wasting your time to read this but i had to reply.
    Please, if any one have more information regarding my issue, it will be highly appreciated.
    Really , thanks all for support.
    Thanks & Regards,

  • I have Acrobat Pro 9.0. Am happy with it since I only have occasional need. Haven't updated it. Is there a way to do this? Do I need toy go through updates sequentially if they are available? Thanks for any help.

    I have Acrobat Pro 9.0. Am happy with it since I only have occasional need. Haven't updated it. Is there a way to do this? Do I need to
    go through updates sequentially if they are available? Thanks for any help.

    Hi Spiral Geronimo,
    It is always recommended to update the software to its latest updates. I would suggest you to update your Acrobat 9 to its latest updates. You can download the updates from the link below:
    http://helpx.adobe.com/acrobat/kb/update-patch-acrobat-reader-7.html

  • The files/project listed below are linked to the open projects may require exporting

    Guys, I'm having this error "$ not a valid integer".
    I have five modules..all in .exe format. 3 of these modules are working fine with the links, 2 modules are not..
    I have 1 .exe as a menu, when I publish this slied..it would say "the files/project listed below are linked to the open projects may require exporting"
    3  modules are having this
    [title.htm,title.swf or title.exe}
    and the remaining 2 are having the full address of the file "c:\documents and settings\ so on and so on"
    what can't be like the 3 modules? I used the same procedure, what could be the problem?

    oopps..this is ok already..done with the updates. thanks

  • What locks are required on a table when Oracle is processing an UPDATE

    What locks are required on a table when Oracle is processing an
    UPDATE statement?

    Welcome to the forum!
    Whenever you post provide your 4 digit Oracle version.
    >
    What locks are required on a table when Oracle is processing an
    UPDATE statement?
    >
    Here is a relevant quote from the 'Lock Modes' section of the doc that Ed Stevens provided
    >
    Assume that a transaction uses a SELECT ... FOR UPDATE statement to select a single table row. The transaction acquires an exclusive row lock and a row share table lock. The row lock allows other sessions to modify any rows other than the locked row, while the table lock prevents sessions from altering the structure of the table. Thus, the database permits as many statements as possible to execute.
    >
    The above describes the locks when you, the user, tells Oracle to lock the row.

  • HT5815 The most important piece of info about an update I need is how much data does it require. I am travelling and using prepaid data. I cannot even consider an update until I know how much data it will use. Please provide this information.

    The most important piece of info about an update I need is how much data does it require. I am travelling and using prepaid data. I cannot even consider an update until I know how much data it will use. Please provide this information.

    http://www.apple.com/feedback/macosx.html

  • Which authorizations are required for assigning a query to a role?

    Hi everybody,
    we try to set up some roles for "reporting power users". These guys should be alble to define new queries using BEx (works fine) and also should be able to assign these new defined queries to a role, so other users can use these roles.
    The idea is simple, but we're searching for the right authorization object (or - as i suppose - set of authorization objects) that enables the user to assign a query to a role (using that "enter to a role" button in the open / save dialog).
    At the moment, the user can user that button, and the role, he should the query assigned to is shown. After selecting the role and clicking button "create" it take some seconds and a message "error when saving. entry has not been created" is shown.
    Obviously, there is a problem with writing the role (or adding the new information to that role).
    So, could anyone help me and provide me with a list of authorization objects that are required.
    Thanks in advance,
      Alfred

    S_RFC
    S_TCODE
    S_USER_GRP
    S_BDS_D
    S_OD_SEND
    S_RS_AUTH
    S_RS_BCS
    S_RS_COMP
    S_RS_COMP1
    S_RS_FOLD
    S_RS_ICUBE
    S_RS_MPRO
    The above mentioned authorization objects are enough to add in the role and required for the accessing a query.
    particularly, S_RS_COMP, S_RS_COMP1, S_RS_MPRO, S_RS_ICUBE are the most important auth objects which are directly getting involved in authorization of a query in a role.
    SO, you have to assign the respective info area, info cube and info providers names in these auth objects.
    The same scenario , i am using in my project to give access to the queries in all the areas for my end users.
    The values and access/authorizations restrictions is up to your project requirement.
    Hope this would help you.

  • What's with the new Firefox 8.0? I made the mistake of updating mine and about 30% of the icons in bookmarks disappeared. It looks like you are requiring a favicon. Anyway, BAD IDEA!!!!!

    What's with the new Firefox 8.0? I made the mistake of updating mine and about 30% of the icons in bookmarks disappeared. It looks like you are requiring a favicon. Anyway, BAD IDEA!!!!!

    Briansyddal - you might be able to manage your phone without a PC, but many of us can't, especially those of us with large iTunes libraries.  How do you propose I manage my 250GB of music using only a phone?  Maybe I could go out and buy 10 iPhones and spread my library out among them!
    Catz537 - I have the same problem as you and I've spent hours on the web trying to find a solution to it.  It was a problem with iOS 7 and  8.1.1 doesn't fix it.  The the only advice from Apple is completely useless because it requires you, effectively, to delete and recreate your iTunes library and lose all your metadata, album art, notes etc and there's also no guarantee it will work.   I wish I could be more help (even more - I wish Apple could be more help) - I updated to 8.1.1 at 1400 today.  At 2200 I'm still "waiting for changes to be applied" for a measly 16GB of music transfer. 

  • Need SQL query as below.

    Hello,
    Can anyone help me out to get an SQL query as mention below.
    table
    dbname
    RecompileStatus
    Name1
    Disable
    Name2
    Enable
    Name3
    Enable
    Name4
    Disable
    I want the results as follows:
    dbname
    RecompileStatus
    dbname1
    RecompileStatus
    dbname2
    RecompileStatus
    dbname3
    RecompileStatus
    Name1
    Disable
    Name2
    Enable
    Name3
    Enable
    Name4
    Disable
    Any help would be appreciated!!

    Below is dynamic query. This should help you
    DECLARE @Table TABLE (dbname NVARCHAR(10),RecompileStatus NVARCHAR(10))
    IF OBJECT_ID('tempdb..#TableSeqenced') IS NOT NULL
    DROP TABLE #TableSeqenced
    IF OBJECT_ID('tempdb..#FinalTable') IS NOT NULL
    DROP TABLE #FinalTable
    CREATE TABLE #TableSeqenced (dbname NVARCHAR(10),RecompileStatus NVARCHAR(10),RowNum NVARCHAR(5))
    CREATE TABLE #FinalTable (ParameterName NVARCHAR(20),ParameterValue NVARCHAR(20))
    DECLARE @RowNum NVARCHAR(5) = '1'
    ,@MaxRowNum NVARCHAR(5)
    ,@SQLQuery NVARCHAR(2000)
    ,@ParameterName NVARCHAR(2000) = ''
    ,@SQLQuery2 NVARCHAR(2000) = ''
    INSERT INTO @Table
    SELECT 'Name1','Disable'
    UNION ALL
    SELECT 'Name2','Enable'
    UNION ALL
    SELECT 'Name3','Enable'
    UNION ALL
    SELECT 'Name4','Disable'
    INSERT INTO #TableSeqenced
    SELECT dbname,RecompileStatus,ROW_NUMBER() OVER (order by dbname) RowNum
    FROM @Table
    SET @MaxRowNum = (SELECT MAX(RowNum) FROM #TableSeqenced)
    WHILE @RowNum <= @MaxRowNum
    BEGIN
    SET @SQLQuery = ''
    SET @SQLQuery = 'INSERT INTO #FinalTable (ParameterName,ParameterValue)
    SELECT ''dbname' + @Rownum + ''' ,(SELECT dbname FROM #TableSeqenced WHERE RowNum = ' + @RowNum + ')
    UNION ALL
    SELECT ''RecompileStatus' + @Rownum + ''' ,(SELECT RecompileStatus FROM #TableSeqenced WHERE RowNum = ' + @RowNum + ')'
    EXEC (@SQLQuery)
    SET @RowNum += 1
    END
    SELECT @ParameterName = @ParameterName + ',' + ParameterName FROM #FinalTable
    SET @ParameterName = SUBSTRING(@ParameterName,2,LEN(@ParameterName) - 1)
    SET @SQLQuery2 = 'SELECT *
    FROM ( SELECT ParameterName,ParameterValue
    FROM #FinalTable ) UNPVT
    PIVOT ( MAX(ParameterValue) FOR ParameterName IN (' + @ParameterName + ' )
    ) PVT'
    EXEC (@SQLQuery2)

  • Ipod cannot update. The required file cannot be found?? Any help please.

    Hi,
    I like many others have major problems with my Ipod, we downloaded the Itunes 6 , removed it, went back to 4.9, connected the Ipod, everything got erased. ( but it was still on the computer thank goodness, anyway now I can't put anything back on to my Ipod, it say "Ipod cannot update. The required file cannot be found"
    I have Windows Xp Pro 2, what can I do, please lead me in the right direction.
    Thanks

    OK - Looks like your iTunes is working and has the songs you expect in it. No need to uninstall iTunes.
    Are the Playlists on the iPod only, or are they in iTunes only, or are they on both? Are they populated with the songs you expect?
    You can save the Playlists by 'Exporting' them individually to a PC file. Within iTunes, select (highlight) a playlist, go to File==>Export Song List and save the file to a 'Playlists' folder that you create. Save the playlists as a .txt and an .xml file (do both for each playlist: data redundancy is good).
    Do you have the original photos that are on the iPod? We will have to Restore the iPod and all data on it will be erased. As you have all the necessary music on iTunes, all we would be concerned about are the photos. Or anything else you haven’t mentioned.
    As long as you are satisfied with the state of your iTunes (all music and playlists present and accounted for), then you can comfortably Restore the iPod and place it all back on the unit. Restoring an iPod will not impact your iTunes. It just clears off the iPod's HD and replaces the operating system with a fresh copy. This should correct your inability to download any additional music to the iPod.
    Before you proceed with the Restore below, make sure that you have copies of all the data on the iPod so you do not lose anything.
    First, make sure that the iPod is fully charged.
    Make sure that you have the latest iPod Updater software (if you already do, skip to *)
    You also need to install the new Updater software (if applicable) by double-clicking on the file that downloads.
    After you install the Updater to your PC, reboot your computer.
    After rebooting, run the Updater.
    * Go to: Start ==> Programs ==> iPod.
    It should initialize then ask you to connect an iPod.
    Connect the iPod when asked (not before) and you should have two options available: Update or Restore.
    -- Choose the Restore option and it will update your iPod's firmware to the latest version and format your iPod's hard drive.
    After the Restore complete, re-register the iPod with iTunes, choose your syncing preference and place the music back on the iPod. Do whatever it is you do with the photos (I just have a mini, so no experience with photos), and you should be good to go.
    Post back if you have any questions. Especially if you are unsure of anything before you perform any additional processes.

Maybe you are looking for