Need Query for Update

CREATE TABLE TEST_MATCH
MTCH1 NUMBER(9),
MTCH2 NUMBER(9),
UPDT_MTCH CHAR(2 BYTE),
UPDT_NBR NUMBER(10)
SET DEFINE OFF;
Insert into TEST_MATCH
(MTCH1, MTCH2, UPDT_MTCH)
Values
(2616131, 300137070, '02');
Insert into TEST_MATCH
(MTCH1, MTCH2, UPDT_MTCH)
Values
(2571056, 300129277, '02');
Insert into TEST_MATCH
(MTCH1, MTCH2)
Values
(2623529, 300175046);
COMMIT;
i need to update the column UPDT_NBR which is currently NULL
UPDATE TEST_MATCH
SET UPDT_NBR =
NVL(2616131, 300137070) FOR THESE TWO MATCHES-> (1234567),
(2571056, 300129277) FOR THESE TWO MATCHES -> (1111111),
(2623529, 300175046) FOR THESE TWO MATCHES ->(222222);
Thanks for all your help in my previous post. And thanks again for looking into my post.

Hi,
If it is just three records it would be better if you fire individual update statement 3 times.
But if it is a sample data only and you have many updates to do then only way I think it is is possible is either by creating temporary table or using subfactoring(same as creating temporary table)
Regards
Anurag

Similar Messages

  • Need Query for empty partitions

    I am having nearly 700 partitions for a table.Now i want to find out only the empty partitions.I need query for that.
    Thankx..

    Not the most elegant solution, but it works:
    declare
    rc number;
    str varchar2(200);
    begin
    for i in (select table_owner, table_name, partition_name from dba_tab_partitions) loop
    str := 'select count(*) from ' || i.table_owner || '.' || i.table_name || ' partition (' || i.partition_name || ')';
    execute immediate str into rc;
    if rc = 0 then
    dbms_output.put_line(i.table_owner || '.' || i.table_name);
    end if;
    end loop;
    end;

  • Query for updating the records

    I have the two tables....
    CREATE TABLE temp_1
    ( ST_NM VARCHAR2(30),STATUS_ID VARCHAR2(1) NOT NULL ENABLE,ST_ID VARCHAR2(20) primary key,REJ_USER_NM varchar2(10))
    sample Data :
    insert into temp_1 values('S010054','R','ST9749109','TEST_1');
    insert into temp_1 values('S010179','R','ST9749147','');
    insert into temp_1 values('S010582','N','ST9749258','');
    CREATE TABLE temp_2
    ( REJ_USER_NM VARCHAR2(20),ST_NM VARCHAR2(30),
    STATUS_ID VARCHAR2(1) NOT NULL ENABLE,ST_ID VARCHAR2(20))
    sample data:
    insert into temp_2 values('','S010054','N','ST9749109');
    insert into temp_2 values('','S010054','N','ST9749109');
    insert into temp_2 values('TEST_1','S010054','N','ST9749109'');
    insert into temp_2 values('','S010054','I','ST9749109');
    insert into temp_2 values('','S010179','N','ST9749147');
    insert into temp_2 values('TEST_2','S010179','N','ST9749147');
    insert into temp_2 values('','S010179','N','ST9749147');
    insert into temp_2 values('','S010179','N','ST9749147')
    insert into temp_2 values('TEST_5','S010582','R','ST9749258');
    insert into temp_2 values('TEST_5','S010582','N','ST9749258');
    insert into temp_2 values('','S010582','N','ST9749258');
    insert into temp_2 values('','S010582','N','ST9749258')
    I want the UPDATE query based on below conditions to update the REJ_USER_NM in temp_1 table.
    From temp_1 table ,STATUS_ID is 'R' and REJ_USER_NM is null and compare the set_id column value
    with the temp_2 table,where REJ_USER_NM is not null and status id is 'N'. REJ_USER_NM column from
    temp_2 table need to be update in the REJ_USER_NM column of temp_1 table.
    After completion of updation,output is in below format; if i run below qry
    ====================================
    select * from temp_1;
    {S010054},{R},{ST9749109},{TEST_1}
    {S010179},{R},{ST9749147},{TEST_2}
    {S010582},{N},{ST9749258},{}
    ======================
    Edited by: 849971 on May 2, 2011 8:25 PM

    Why is that the row
    {S010582},{N},{ST9749258},{}
    is not updated to TEST_5 ?? Based on your rules and data. it must be updated to test_5. Are you missng any rules?
    Try some thing like,
    UPDATE temp_1
       SET REJ_USER_NM  =
              (SELECT REJ_USER_NM
                 FROM temp_2
                WHERE     status_id = 'N'
                      AND temp_1.st_id = temp_2.st_id
                      AND temp_2.REJ_USER_NM IS NOT NULL)

  • SQL Query for update

    hi experts
    I got two tables
    BOOK (DDC,TITLE,ISBN,AUTH_NAME)
    AUTHOR (ID,DDC,AUTH_NAME)
    AUTH_NAME column in BOOK's table contains NULL for all records.
    I want update table BOOK's column AUTH_NAME from AUTHOR's column in AUTHOR table where DDC numbers match. DDC is not unique in AUTHOR's table. I want to update BOOK table with the first matching AUTH_NAME. Rest should be ignored.
    Please write me the query for it.
    thanks

    Please write me the query for it.This fellow has no questions.
    Please, DO NOT ANNOY HIM with hints and tips, he just wants his answer. ; )
    I suspect it's homework, just another cheating student, earning his OCP.
    He is very anxious to get somebody to do his work, as he has spammed this same questtion on several other Oracle forums:
    http://dba.ipbhost.com/index.php?showtopic=10441
    http://www.dba-village.com/village/dvp_forum.OpenThread?ThreadIdA=32264

  • Parallel query for UPDATE

    Hi,
    In the documentation of Oracle 10.2 -> Data Warehousing guide -> Ch.25 Using Parallel execution, search for section labeled "Rules for UPDATE, MERGE and DELETE", it is mentioned that,
    "UPDATE, MERGE, and DELETE operations are parallelized by partition or subpartition. Update, merge, and delete parallelism are not possible within a partition, nor on a nonpartitioned table"
    I am on 10.2 Enterprise edition, Solaris. I can see that, I can parallelize an UPDATE command (commands pasted below).
    Please can somebody explain me, what am I missing ??
    SQL> drop table r1 ;
    Table dropped.
    SQL> create table r1 as select * from user_objects where 1=2 ;
    Table created.
    SQL> exec dbms_stats.set_table_stats( ownname=>'solarp', tabname=>'R1', numrows=> 100000000, numblks=>251342 ) ;
    PL/SQL procedure successfully completed.
    SQL> alter table r1 parallel 5 ;
    Table altered.
    SQL> set autotrace traceonly explain
    SQL> update r1 set status='XX' where created > ( sysdate - 7) ;
    0 rows updated.
    Execution Plan
    Plan hash value: 1840129185
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | TQ |IN-OUT| PQ Distrib |
    | 0 | UPDATE STATEMENT | | 5000K| 66M| 14083 (14)| 00:02:49 | | | |
    | 1 | UPDATE | R1 | | | | | | | |
    | 2 | PX COORDINATOR | | | | | | | | |
    | 3 | PX SEND QC (RANDOM)| :TQ10000 | 5000K| 66M| 14083 (14)| 00:02:49 | Q1,00 | P->S | QC (RAND) |
    | 4 | PX BLOCK ITERATOR | | 5000K| 66M| 14083 (14)| 00:02:49 | Q1,00 | PCWC | |
    |* 5 | TABLE ACCESS FULL| R1 | 5000K| 66M| 14083 (14)| 00:02:49 | Q1,00 | PCWP | |
    Predicate Information (identified by operation id):
    5 - filter("CREATED">SYSDATE@!-7)
    Thanks in advance

    The manuals get out of date and out of synch. Somewhere in the 9i manuals it says that there is "limited" support for all parallel DML. Your plan, as David said, is a parallel select with serial update - if you want to perform the update in parallel then you need an explicit:
    alter session enable parallel dml;Here's a plan (pulled from v$sql_plan in 10.2.0.3) for a similar update to yours. This plan is the parallel update version:
    update t1 set n1 = 0 where mod(id,100) = 0
    | Id  | Operation             | Name     | Rows  | Bytes | Cost (%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |
    |   0 | UPDATE STATEMENT      |          |       |       |   753 (100)|          |        |      |            |
    |   1 |  PX COORDINATOR       |          |       |       |            |          |        |      |            |
    |   2 |   PX SEND QC (RANDOM) | :TQ10000 |   100 |   800 |   753   (0)| 00:00:10 |  Q1,00 | P->S | QC (RAND)  |
    |   3 |    UPDATE             | T1       |       |       |            |          |  Q1,00 | PCWP |            |
    |   4 |     PX BLOCK ITERATOR |          |   100 |   800 |   753   (0)| 00:00:10 |  Q1,00 | PCWC |            |
    |*  5 |      TABLE ACCESS FULL| T1       |   100 |   800 |   753   (0)| 00:00:10 |  Q1,00 | PCWP |            |
    Predicate Information (identified by operation id):
       5 - access(:Z>=:Z AND :Z<=:Z)
           filter(MOD("ID",100)=0)Note, particularly, that the UPDATE operation is the child of the PX SEND to coordinator. i.e. we update in the PX slaves, then tell the co-ordinator what we updated.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk

  • Need help for Update and cancel SalesOrder

    Hi All,
    I  written java code for create sales order based on salesquotation,now i want to update and cancel sales order ,i need help to update and cancel salesorder.
    can give any related links for update and cancel salesorder.
    Thanks and Regards,
    Srinivas

    Hi srinivas.L
    It is simple, here is some sample code. You must use getbykey to get the document. Then once you got it you can make whatever changes you need. Then update it. where i have oOrder.Update() you can have oOrder.cancel
    Dim oOrder As SAPbobsCOM.Documents
            oOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
            If oOrder.GetByKey(530) Then
                oOrder.Lines.SetCurrentLine(1)
                oOrder.Lines.WarehouseCode = "01"
                If oOrder.Update() <> 0 Then
                    MsgBox(oCompany.GetLastErrorDescription)
                End If
            Else
                MsgBox("Nothing found")
            End If
    Hope this helps

  • Need help to write a query for Update statement with  join

    Hi there,
    The following update statement gives me error as the given table in set statement is invalid. But its the right table .
    Is the statement correct? Please help .
    update (
           select distinct(vpproadside.VEHICLE_CRED_OVERRIDE.vin)            
             from vpproadside.VEHICLE_CRED_OVERRIDE
             join vpproadside.vpp_vehicle
               on vpproadside.vpp_vehicle.vin = vpproadside.VEHICLE_CRED_OVERRIDE.vin
            where VPP_CARRIER_SEQ_NUMBER = 90
              and EXPIRY_DATE = '17-MAR-10'
       set vpproadside.VEHICLE_CRED_OVERRIDE.EXPIRY_DATE = '15-SEP-10';Edited by: Indhu Ram on Mar 12, 2010 1:00 PM
    Edited by: Indhu Ram on Mar 12, 2010 1:22 PM
    Edited by: Indhu Ram on Mar 12, 2010 2:35 PM
    Edited by: Indhu Ram on Mar 15, 2010 8:04 AM
    Edited by: Indhu Ram on Mar 15, 2010 8:06 AM
    Edited by: Indhu Ram on Mar 15, 2010 8:28 AM

    Ask Tom has very good discussion about this, if UPDATE does not work for PK issue, you can use MERGE
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:760068400346785797

  • Query for updating prices if product IDs same

    I have a large Windows SQL 2000 database of products that
    need to have
    2007 prices.
    I have another Windows SQL 2000 database that has the correct
    prices
    that I can import into Windows SQL 2000 as a new table.
    I want to be able to UPDATE the Prices where product IDs
    match.
    What would an SQL query look like that would run in Query
    analyzer?
    So, basically, I need a query that would compare the product
    IDs and
    update the price column with the new price.
    Neither database is in the same location. One that holds the
    correct
    pricing is basically inaccessible to me. I can get a
    delimited file
    though. I know how to get that in.

    I've a table called Track, which has three columns named Part1, Part2 and Part3. I want all values of Part1 to be separated by a comma (,);
    No, don't go there.
    This breaks a fundamental point for relational databases: no repeating groups. A cell should hold an atomic value. And this is not only a matter of purism. Relational databases are designed from this principle, and breaking this means that you will need
    to write complex and higly inefficient code.
    The values in Part1 should be in a separate table, with one value per row.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Query for Updation!!!

    Hi,
    I am working on some retail related.our client is having some vendors.so every month we are calculating the total sales about the products.
    Means we have "TotaL Current Sales" and Prevous "Month sales amt".
    By using these two we are preparing statements for that particular vendor for that particular month and the previous month.
    But the problem is am getting... when I am tryiyng to update the Previous MOnth amt it is getting updated but while preparing the statement it is showing the old value instead of new value.
    can you please help me out to resolve it.
    Eg : Current Month sales : 23,000,000
    Previous MOnth Sales : 13,000,000
    Here I have written the update statement to update the Previous month sales as 11,000,000.
    then it is showing the sales as 11,000,000.
    But while preparing the statement it is showing the Previous month sales as 13,000,000 only.But I want to display it as 11,000,000.
    can you please help me out to write a query or Procedure/Function or any thing which is required for this.
    Thanks in advance.

    Give us the following details.
    1. DB Version.
    2. Table structure
    3. Sample Data
    4. SQL Statement Executed by You.
    Use {noformat}{noformat} tags when you post the above details to preserve the code format.
    You can use it like this
    <your code here>\                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Need API for updating vacancy in "DateTrack History of Assignments"

    Hi Friends,
    I am updating organization,job,location and Grade through hr_assignment_api.update_emp_asg_criteria at assignment level. Here I want to update the vacancy Name located at "DateTrack History of Assignments". WHich API I need to use to update "DateTrack History of Assignments".
    "DateTrack History of Assignments"
    For Getting this screen, goto Assignment screen,
    then click on "Date Track History"
    then click on "full History".
    I am seeing old vacancy names but not new one. I need to update that vacance name.
    Thanks in advance

    Hi Subhabrata,
    I am not sure if there is any standard API to do this update.
    Looks like you have requirement to pay the commission only when the invoice is fully paid.
    Customizing like this is not the best option. There are outbox ways to design the collection/plan so that you pay commission when the invoice is paid.
    Thanks
    Srini Parimi
    Edited by: user12263675 on Dec 29, 2009 10:40 AM

  • Need Query for Item Relationship of Oracle Apps

    Hello Team,
    I need the Query to select the Item Relationship.
    In Oracle Apps we have different tyes of Structure
    ItemA -> ItemB
    ItemB -> ItemC
    ItemC -> ItemD
    ItemG -> ItemH
    ItemK -> ItemL
    ItemW -> ItemQ
    and this also is possible (meand many to one relationship)
    ItemA -> ItemB
    ItemB -> ItemC
    ItemC -> ItemD
    ItemT -> ItemD
    and in the Select Query i want the below result
    ItemA -> ItemB 1
    ItemB -> ItemC 2
    ItemC -> ItemD 3
    ItemG -> ItemH 1
    ItemK -> ItemL 2
    ItemW -> ItemQ 1
    and this also is possible (means many to one relationship)
    ItemA -> ItemB 1
    ItemB -> ItemC 2
    ItemC -> ItemD 3
    ItemT -> ItemD 1
    means i want the Hierarchy number also
    Please help me to in order to get the relationship by sql query.
    Kind Regards,

    thanks for the quick response and i would love to spend time perusing the forum for this question but i didn't have time today.  i'll do that now though.
    what i'm mostly interested in is a chronological view (lastUpdateDate) of the change to pricing for an item in the system.  there is a lot of activity in our system around price changes for promotions and i want to keep track of when it's changed in the source system and pair that with our other downstream systems.
    i'm assuming we can add this functionality through a udf some way or maybe sp_TransNotification proc?

  • Need query for requistion and rfq numbers

    Dear All,
    I need a query to list all requisition number for which RFQ is created and RFQ  is partially converted to PO, if RFQ is fully converted to PO, it should not fetch the details.please help me on this.
    Thanks
    Debendra

    Are you referring to sourcing RFQ or core quotations?

  • Need query for Item - Price Change History

    I need help finding information around Price Change History by Price List. 
    Information of interest is Date of Update and By Whom.    Also, if a Datasource is 'N-Unknown', what does this generally mean?
    select
    i.itemcode,
    i.itemname,
    iphist.price,
    pl.listname,
    pl.datasource as 'ChangeSource',
    '' as 'PriceChangeUpdateDate',
    '' as 'UpdateByUser'
    from  ait1 iphist, oitm i, opln pl
    where 1=1
    and iphist.pricelist = pl.listnum
    and i.itemcode = iphist.itemcode
    and iphist.itemcode in ('1234')
    and pl.listnum in (6)
    thanks in advance...

    thanks for the quick response and i would love to spend time perusing the forum for this question but i didn't have time today.  i'll do that now though.
    what i'm mostly interested in is a chronological view (lastUpdateDate) of the change to pricing for an item in the system.  there is a lot of activity in our system around price changes for promotions and i want to keep track of when it's changed in the source system and pair that with our other downstream systems.
    i'm assuming we can add this functionality through a udf some way or maybe sp_TransNotification proc?

  • Form on SQL query for updating.

    Hello again,
    Im trying to wirte a form to udapte the information in a table. I have a table with a PK which holds a persons name, and an activity assigned to them (and loads of other fields but they dont matter atm). I would like to have a form which has an SQL query running in one region and then the form underneath to be able to edit (reassign a person to a different activity) an item appearing in the query result. Ive got a form at the moment which is form on an sql query but its not updating when i fill out the form, is it something to do with the regions?
    http://img.photobucket.com/albums/v611/Funky_Monk/untitled.jpg
    So on the screenie, i have the bottom region for the query (no values in table hence the error (i think!))
    The call ID is FK to another table
    severity level and status will be usdated here
    description is self-explanitory
    analyst_id is the main field to be changed here, the call id will be assigned a new analyst via this form.
    action_id is actions carried out on this problem.
    Any help would be greatly appreciated.
    DM

    hi,
    Can you put this example on apex.oracle.com?
    Regards,
    Kartik Patel
    http://patelkartik.blogspot.com/
    http://apex.oracle.com/pls/apex/f?p=9904351712:1

  • [Solved partially] Sql query for updates compliance

    Hello
    I'm trying (with no success) to translate the "Software+Updates+-+A+Compliance%2fCompliance+1+-+Overall+compliance" report into a sql query that must run for a specific
    Software update group and for a specific Collection ID.
    The expected result should be like the report it self, I mean 3 lines with Kpi (pourcentage).
    The main query in this report is : 
    select
    CollectionID=@CollID,
    Status=sn.StateName,
    cs.NumberOfComputers,
    PComputers=convert(float, isnull(cs.NumberOfComputers, 0)*100.00) / isnull(nullif(cs.NumTotal, 0), 1),
    AuthListID=@AuthListID
    from (select CI_ID, NumTotal, [0]=NumUnknown, [1]=NumPresent+NumNotApplicable, [2]=NumMissing
    from fn_rbac_UpdateSummaryPerCollection(@UserSIDs)
    where CI_ID=@CI_ID and CollectionID=@CollID
    ) cnt
    unpivot (NumberOfComputers for [Status] in ([0], [1], [2])) cs
    left join fn_rbac_StateNames(@UserSIDs) sn on sn.TopicType=300 and sn.StateID=cs.Status
    where cs.NumberOfComputers>0
    order by cs.NumberOfComputers desc
    I have no clue on how to replace or use fr_rbac view when run outside a report.
    Can you please help me ?
    Thanks

    Hi,
    Glad to hear that and thank you for your sharing.
    Best Regards,
    Joyce
    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.

Maybe you are looking for

  • How do I resync a song manually deleted on iPhone with 'swipe to delete'?

    I accidently deleted a song while browsing music on my iPhone (with the swipe to delete function) and now I am not able to resync the song back onto the phone even though it's still happily there in iTunes on my iMac. I've tried explicitly adding it

  • Help upgrade to Digital Vault Plus

    I have recently left bt broadband and had an email notifying me that my digital vault would be cancelled unless i upgrade to digital vault plus.  I have tried to do this but when I go to upgrade and enter my payment details it says it is undergoing m

  • OIM 11g r1 custom field in simple user search result

    Good morning, i need to visualize a custom field in the OIM simple user search result table. At the moment, when a simple user search is performed, the returned attribute is only the "Display Name". For the advanced user search result table, is possi

  • Increasing S/A Comm TIMEOUT

    Hi All, We are facing a problem in BPM with S/A Bridge. In the BPM we are synchronously calling multiple stored procedures. Each of these stored procedures will take 10-1200Secs for sending back the reponse. Last step in the BPM is to close the S/A B

  • Call of an external web service out of the ABAP-Stack

    Hi experts, i have to implement a call of an external webservice out of the ABAP-stack. Directly from an ABAP-report, not using any PI/XI. The only thing the one implemented the service could give me was a description of the SOAP-call which should ta