PLS CONVERT QUERY-  UPDATE to MERGE

Hi all,
Can you help me in converting this update statement into merge? I will really appreciate your help. Thanks
UPDATE dm_organizations tt
SET (cost_ctr_desc, cost_ctr_hier_lvl_1, cost_ctr_hier_lvl_2,
cost_ctr_hier_lvl_3, cost_ctr_hier_lvl_4, cost_ctr_hier_lvl_5, rgn_nm,
cntry_nm, load_date, update_date) =
(SELECT t.cost_ctr_desc, t.cost_ctr_hier_lvl_1,
t.cost_ctr_hier_lvl_2, t.cost_ctr_hier_lvl_3,
t.cost_ctr_hier_lvl_4, t.cost_ctr_hier_lvl_5, t.rgn_nm,
t.cntry_nm, t.load_date, SYSDATE
FROM dmi_cc_upload_stg t
WHERE t.run_id = 1831
AND t.status = 'Published'
AND t.cost_ctr_id = tt.cost_ctr_id
AND t.div_code = tt.div_code
AND t.fcn_code = tt.fcn_code
AND t.mkt_code = tt.mkt_code
AND t.corp_id = tt.corp_id
AND ROWNUM = 1)
WHERE EXISTS (
SELECT t.cost_ctr_desc, t.cost_ctr_hier_lvl_1,
t.cost_ctr_hier_lvl_2, t.cost_ctr_hier_lvl_3,
t.cost_ctr_hier_lvl_4, t.cost_ctr_hier_lvl_5, t.rgn_nm,
t.cntry_nm, t.load_date, SYSDATE
FROM dmi_cc_upload_stg t
WHERE t.run_id = 1831
AND t.status = 'Published'
AND t.cost_ctr_id = tt.cost_ctr_id
AND t.div_code = tt.div_code
AND t.fcn_code = tt.fcn_code
AND t.mkt_code = tt.mkt_code
AND t.corp_id = tt.corp_id);

Duplicate thread!
PLS HELP CONVERT QUERY FROM UPDATE TO MERGE

Similar Messages

  • PLS HELP CONVERT QUERY FROM UPDATE TO MERGE

    Hi all,
    Can you help me in converting this update statement into merge? I will really appreciate your help. Thanks
    UPDATE dm_organizations tt
    SET (cost_ctr_desc, cost_ctr_hier_lvl_1, cost_ctr_hier_lvl_2,
    cost_ctr_hier_lvl_3, cost_ctr_hier_lvl_4, cost_ctr_hier_lvl_5, rgn_nm,
    cntry_nm, load_date, update_date) =
    (SELECT t.cost_ctr_desc, t.cost_ctr_hier_lvl_1,
    t.cost_ctr_hier_lvl_2, t.cost_ctr_hier_lvl_3,
    t.cost_ctr_hier_lvl_4, t.cost_ctr_hier_lvl_5, t.rgn_nm,
    t.cntry_nm, t.load_date, SYSDATE
    FROM dmi_cc_upload_stg t
    WHERE t.run_id = 1831
    AND t.status = 'Published'
    AND t.cost_ctr_id = tt.cost_ctr_id
    AND t.div_code = tt.div_code
    AND t.fcn_code = tt.fcn_code
    AND t.mkt_code = tt.mkt_code
    AND t.corp_id = tt.corp_id
    AND ROWNUM = 1)
    WHERE EXISTS (
    SELECT t.cost_ctr_desc, t.cost_ctr_hier_lvl_1,
    t.cost_ctr_hier_lvl_2, t.cost_ctr_hier_lvl_3,
    t.cost_ctr_hier_lvl_4, t.cost_ctr_hier_lvl_5, t.rgn_nm,
    t.cntry_nm, t.load_date, SYSDATE
    FROM dmi_cc_upload_stg t
    WHERE t.run_id = 1831
    AND t.status = 'Published'
    AND t.cost_ctr_id = tt.cost_ctr_id
    AND t.div_code = tt.div_code
    AND t.fcn_code = tt.fcn_code
    AND t.mkt_code = tt.mkt_code
    AND t.corp_id = tt.corp_id);

    why not use existing UPDATE?
    UPDATE dm_organizations tt
    SET    ( cost_ctr_desc, cost_ctr_hier_lvl_1, cost_ctr_hier_lvl_2,
             cost_ctr_hier_lvl_3,
             cost_ctr_hier_lvl_4, cost_ctr_hier_lvl_5, rgn_nm, cntry_nm,
             load_date, update_date ) = (SELECT t.cost_ctr_desc,
                                                t.cost_ctr_hier_lvl_1,
                                                t.cost_ctr_hier_lvl_2,
                                                t.cost_ctr_hier_lvl_3,
                                                t.cost_ctr_hier_lvl_4,
                                                t.cost_ctr_hier_lvl_5,
                                                t.rgn_nm,
                                                t.cntry_nm,
                                                t.load_date,
                                                SYSDATE
                                         FROM   dmi_cc_upload_stg t
                                         WHERE  t.run_id = 1831
                                                AND t.status = 'Published'
                                                AND t.cost_ctr_id = tt.cost_ctr_id
                                                AND t.div_code = tt.div_code
                                                AND t.fcn_code = tt.fcn_code
                                                AND t.mkt_code = tt.mkt_code
                                                AND t.corp_id = tt.corp_id
                                                AND ROWNUM = 1)
    WHERE  EXISTS (SELECT t.cost_ctr_desc,
                          t.cost_ctr_hier_lvl_1,
                          t.cost_ctr_hier_lvl_2,
                          t.cost_ctr_hier_lvl_3,
                          t.cost_ctr_hier_lvl_4,
                          t.cost_ctr_hier_lvl_5,
                          t.rgn_nm,
                          t.cntry_nm,
                          t.load_date,
                          SYSDATE
                   FROM   dmi_cc_upload_stg t
                   WHERE  t.run_id = 1831
                          AND t.status = 'Published'
                          AND t.cost_ctr_id = tt.cost_ctr_id
                          AND t.div_code = tt.div_code
                          AND t.fcn_code = tt.fcn_code
                          AND t.mkt_code = tt.mkt_code
                          AND t.corp_id = tt.corp_id); 

  • Corellated update AND merge(update only)

    Hi ,
    I have few corellated updates in my code , which i though ,i can replace with 10g new Merge update only stmt.
    But to my surprise , the sql using merge is showing more cost and using full table scan.
    Please find below the sql stmts. below(example). Am using Oracle 10.2.0.1
    create table t1 as select * from all_objects where rownum<10000;
    create table t2 as select * from t1 where rownum<10000-200;
    create unique index t1_objId_ind on t1(object_id);
    create unique index t2_objId_ind on t2(object_id);
    --Corellated updated query
    update t1 set t1.object_name= (select upper(t2.object_name) from t2 where t1.object_id=t2.object_id)
    where T1.OBJECT_ID IN (SELECT t2.object_id from t2);Explan for above update stmt.
    | Id  | Operation                    | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | UPDATE STATEMENT             |              |  9139 |   383K|    37   (9)| 00:00:01 |
    |   1 |  UPDATE                      | T1           |       |       |            |          |
    |   2 |   NESTED LOOPS               |              |  9139 |   383K|    37   (9)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL         | T1           |  9138 |   267K|    35   (3)| 00:00:01 |
    |*  4 |    INDEX UNIQUE SCAN         | T2_OBJID_IND |     1 |    13 |     0   (0)| 00:00:01 |
    |   5 |   TABLE ACCESS BY INDEX ROWID| T2           |     1 |    30 |     2   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    |*  6 |    INDEX UNIQUE SCAN         | T2_OBJID_IND |     1 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("T1"."OBJECT_ID"="T2"."OBJECT_ID")
       6 - access("T2"."OBJECT_ID"=:B1)I wanted to eliminate the corellated update , So i wrote using MERGE as below
    MERGE INTO T2
    USING T1
    ON (t1.object_id=t2.object_id)
    WHEN MATCHED THEN update
      SET T2.OBJECT_NAME=UPPER(T1.OBJECT_NAME);Explan for above MERGE stmt.
    | Id  | Operation            | Name | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | MERGE STATEMENT      |      |  9139 |   303K|       |   201    (2)| 00:00:03 |
    |   1 |  MERGE               | T2   |       |       |       |            |          |
    |   2 |   VIEW               |      |       |       |       |            |          |
    |*  3 |    HASH JOIN         |      |  9139 |  2391K|  1256K|   201   (2)| 00:00:03 |
    |   4 |     TABLE ACCESS FULL| T1   |  9138 |  1142K|       |    35   (3)| 00:00:01 |
    |   5 |     TABLE ACCESS FULL| T2   |  9671 |  1322K|       |    34   (3)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       3 - access("T1"."OBJECT_ID"="T2"."OBJECT_ID")Cost is 201 , but for the corellated update the cost is 37.
    Any idea , how should i re-write the MERGE stmt.?
    Edited by: kumar on Jun 16, 2011 4:41 PM

    First "cost" is just a number and you should not compare or tune to get the best "cost" in an execution plan.
    What counts ist elapsed time => IO, CPU...
    In 11g the "cost" for the merge is better (and also the CPU time is far off to be close to the truth!)
    9799 rows updated
    78ms elapsed
    Plan hash value: 580992724
    | Id  | Operation                    | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | UPDATE STATEMENT             |              |  9641 |   404K| 28964  (34)| 00:05:48 |
    |   1 |  UPDATE                      | T1           |       |       |            |          |
    |   2 |   NESTED LOOPS               |              |  9641 |   404K|    41   (3)| 00:00:01 |
    |   3 |    TABLE ACCESS FULL         | T1           | 10866 |   318K|    40   (0)| 00:00:01 |
    |*  4 |    INDEX UNIQUE SCAN         | T2_OBJID_IND |     1 |    13 |     0   (0)| 00:00:01 |
    |   5 |   TABLE ACCESS BY INDEX ROWID| T2           |     1 |    30 |     2   (0)| 00:00:01 |
    |*  6 |    INDEX UNIQUE SCAN         | T2_OBJID_IND |     1 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("T1"."OBJECT_ID"="T2"."OBJECT_ID")
       6 - access("T2"."OBJECT_ID"=:B1)
    Note
       - dynamic sampling used for this statement (level=2)
    commited
    16ms elapsed
    9799 rows merged
    125ms elapsed
    Plan hash value: 2009158753
    | Id  | Operation            | Name | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | MERGE STATEMENT      |      |  9641 |   320K|       |   251   (1)| 00:00:04 |
    |   1 |  MERGE               | T2   |       |       |       |            |          |
    |   2 |   VIEW               |      |       |       |       |            |          |
    |*  3 |    HASH JOIN         |      |  9641 |  3088K|  1720K|   251   (1)| 00:00:04 |
    |   4 |     TABLE ACCESS FULL| T2   |  9640 |  1600K|       |    39   (0)| 00:00:01 |
    |   5 |     TABLE ACCESS FULL| T1   | 10866 |  1676K|       |    40   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - access("T1"."OBJECT_ID"="T2"."OBJECT_ID")
    Note
       - dynamic sampling used for this statement (level=2)In your example, the elapsed time (thanks for the it!) is 78ms for the update and 125ms for the MERGE. (ORACLE 11g on and old PC) .
    So "should you rewrite" the MERGE? No idea how. I assume you want to change from UPDATE to MERGE and see if it's worth?
    Here it's not. But, your example just uses 2MB of data. And the difference from my point view is not MERGE or UPDATE it's NL against HASH join with that tiny amount of data.
    So generally I use MERGE because of speed and because I have more control over the query. For updating 2MB of data, it's not worth it. For updating GBytes the stuff I worked on it was faster (and better to control).

  • Converting  an update statement to modify statement in BADI

    Hai I want to convert an update statement to  nodify statement . Can we define the internal table in BADI. Give me the code

    Hi,
    We can define internal tables in BADI.
    Example:
    Implement BADI ME_PROCESS_PO_CUST and in the method PROCESS_ITEM
    DATA: ls_mepoitem TYPE mepoitem.
    *get item data
    ls_mepoitem = im_item->get_data( ).
    IF ls_mepoitem-adrn2 EQ space AND
    ls_mepoitem-adrnr EQ space.
    Retrieve the adddres or hardcode as per ur reqmt.
    *transfer the address to ls_mepoitem-adrn2.
    MOVE v_adrn2 TO ls_mepoitem-adrn2.
    CALL METHOD im_item->set_data
    EXPORTING
    im_data = ls_mepoitem.
    ENDIF.
    Asha

  • Asking about query update sql to UDF or UDT

    Hi experts,
    Is it possible to do a query update/ insert SQL to  UDT or UDF in SP notification ? I don't touch any core SAP's table. Just to UDF of UDT that i create  myself. Is it possible ?
    thanks in advance
    regards
    KK

    To Rahul,
    Thanks For your answer . So what is differences between SBO_SP_PostTransactionNotice and SBO_SP_TransactionNotification ? Usually i use SBO_SP_TransactionNotification for blocking some document or alert. So how about SBO_SP_PostTransactionNotice ?
    Please tell me. I'm new in this.
    To Gordon ,
    So can i just make a query insert sql to UDT in SBO_SP_TransactionNotification ?
    Thanks in advance
    Regards
    KK

  • How to update the merged customer information in custom tables?

    The "Setup merge Dictionary" is provided only to register APIs that would be called to update the merged information for parties.
    Is there a similar feature for the account merge?
    If anyone has any ideas of how to update the columns like customer_id, cust_acct_site_id etc. in custom tables at the end of customer merge, please let me know. Any sample code would be of great help.
    Please let me know ASAP.
    Thanks in advance,

    There is one method which I have used. The crm side uses a file called jtf_hooks_data. There is no guarantee that it will work in the future and you will have to test it. The merge program uses this sql
    'SELECT hook_package, hook_api,product_code ' ||
    'FROM jtf_hooks_data '||
    'WHERE package_name = ''ARP_CMERGE_MASTER'' ' ||
    'AND api_name = ''MERGE_PRODUCTS'' ' ||
    'AND execute_flag = ''Y'' ' ||
    'ORDER BY execution_order ';
    Your procedures have to have the same signature as the one being called. Issues the select statement on your system and see what is returned.

  • Power Query Update breaks connection to PostgreSQL database

    After the update to Power Query 2.11.3625.144, we can't connect our PostgreSQL database anymore. 
    Error message is: 
    DataSource.NotFound: PostgreSQL: Unable to find a database provider with invariant name 'Npgsql'.
    This error may have been the result of provider-specific client software being required but missing on this computer.  To download client software for this provider, visit the following site and choose at minimum 'Npgsql version 2.0.12': http://go.microsoft.com/fwlink/?LinkID=282716
    Readding the Npgsql driver doesn't solve the issue. Has the version requirement changed with the Power Query update? Or is PostgreSQL connectivity completely broken?

    Hmm, 
    If I add the line, I get the following error message in Power Query: 
    'Npgsql' returned the error: 'Unrecognized element. (C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config line 169)'.
    This error may have been the result of provider-specific client software being required but missing on this computer.  To download client software for this provider, visit the following site and choose at minimum 'Npgsql version 2.0.12': http://go.microsoft.com/fwlink/?LinkID=282716
    The code in the machine config looks like this: 
      <system.data>
            <DbProviderFactories />
            <add description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=2.0.12.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" name="Npgsql Data Provider" invariant="Npgsql" support="FF"/>
        </system.data>
    The node seems to be empty by default. Can it be that the surrounding stuff has to be differently written in that case?

  • Cannot locate policy manager query/update service

    Hi,
    I installed soa_server 11.1.1.4.0 on windows server 2003 machine, I got a weird issue while accessing the weblogic policy manager through em. I logged into em console, weblogic domain, domain, webservvice, policy throw this erro below
    "*Cannot locate policy manager query/update service. Policy manager service look up did not find a valid service, due to: Unable to connect to WS Policy Manager. <- oracle.wsm.policymanager.PolicyManagerException: WSM-02118 : The query service cannot be created. <- javax.naming.NameNotFoundException: While trying to lookup 'QueryService#oracle.wsm.policymanager.ejb.IStringQueryServiceRemote' didn't find subcontext 'QueryService#oracle'. Resolved ''; remaining name 'QueryService#oracle/wsm/policymanager/ejb/IStringQueryServiceRemote'*"
    even my wls-m is running , I can access the http://host/wls-pm.
    Last three days I have spend for this issue but no clue.I disabled SSL, enable with SSL host validation false but also get this error.Please sort out this issue.
    Thanks
    Govindan

    Problem solved.
    Soln:
    Given ip address in the Listen Address field of weblogic Admin and SOA server. :)
    Thanks
    Govindan P

  • Urgent to UPLOAD teh sapscritp only upload pls read query fully before answ

    urgent to UPLOAD teh sapscritp only upload pls read query fully before answering the query so as to avoid unwantd and unnecessry answers
    i want to load a external ITF script file to SAP and there is no way i want to donload it , i just want to load a external script file named zeg.itf to sap
    pls tell me the whole process as ih ave tried all programs none worked
    1) tell me the process to upload frm rstxscrp... step wise
    it asks for some dev class and wheni give it i doesnt move ahead .. so thts why i asked for the whole process...
    2) by any other program
    3) i knw the program names rstsr3tr a nd rstxscrp what is the diffrence between the two
    and plse let me know the whole process to upload?
    regards
    Arora

    Hi,
    1. selected the radio button "form"
    2. Gave the name of my new sapscript form
    3. mentioned IMPORT
    4. ran the program.
    5. During the program i selected the file (.txt) from where the form would be uploaded from.
    6. Object was created and activated .
    In ur case , u r saying that it is asking for the development clas, so please provide the same...
    It's nothing but the package name...
    If u dont have idea regarding the development class., save it to "$tmp" (as a local object)..That will be done...
    Cheers,
    Simha.
    Reward all the helpful answers...

  • Cannot convert msaccess update query to view

    Hello,
    I am trying to migrate an msaccess database to oracle using oracle sql developer. The problem is that I get error messages when I convert the captured access model to an oracle model.
    I only get error messages on the converted views. These are originally update queries in access like the following example:
    UPDATE [Tbl Zuguebersicht CMA] INNER JOIN 1_PrioTab ON [Tbl Zuguebersicht CMA].Zugnummer = [1_PrioTab].ZugNr SET [Tbl Zuguebersicht CMA].Prioritaet = [1_PrioTab]![InternePrio];
    In the captured model this query is already listed under the node for views. When I convert the model, I get the error message that it cannot be converted.
    If I got it right, an update query cannot be converted to a view, is that correct? So it should rather be a function. I couldn't find a possibility to change this!
    Or am I on the wrong track and there is just a special problem with exactly this update query? But then again, all the update queries could not be converted!
    Help would greatly be appreciated! Thanks in advance...
    Edited by: user8772417 on Sep 17, 2009 8:54 AM

    Thanks for your answers!
    Well I guess then I I have to create the stored procedures myself after the conversion and delete the useless views. That shouldn't be a big deal! I only wanted to avoid searching for the code lines where the stored procedure has to be called - therefore, the automatic way would have been much more comfortable :-)
    I will request this feature on the sql developer page. I can't imagine I am the only one facing this particular MS Access conversion problem.
    Thanks again,
    Max

  • MERGE CONVERT TO UPDATE LOT OF ERROR OCCUR HOW TO CHANGE

    in this statement change merge to update plz help me
    MERGE INTO CORM_QWD_QUOTE_WUTASK A
    USING (SELECT * FROM CORM_QMD_QUOTEMAT) B
    ON ( ( A.QWD_ORDER_OU = B.QMD_ORDER_OU
    AND A.QWD_ORDER_NO = B.QMD_ORDER_NO
    AND A.QWD_AMEND_NO = B.QMD_AMEND_NO
    AND A.QWD_REF_LINE_NO = B.QMD_REF_LINE_NO
    AND A.QWD_TASK_LINE_NO = B.QMD_LINE_NO )
    AND A.QWD_ORDER_OU = v_CUSORDEROU_TMP
    AND A.QWD_ORDER_NO = v_CUSORDERNO_TMP
    AND A.QWD_AMEND_NO = v_CoAmendmentNo_Tmp
    AND ( ( v_DesignParamCode04 = 'ACT'
    AND A.QWD_QUOT_STATUS NOT IN ( 'PL','C' )
    OR ( v_DesignParamCode04 'ACT'
    AND A.QWD_QUOT_STATUS NOT IN ( 'PENC','PL','C' )
    -- IERA-711
    WHEN MATCHED THEN UPDATE SET A.QWD_QUOT_STATUS = CASE
    WHEN A.QWD_QUOT_STATUS IN ( 'PLM','PM','PMC1','PENC','PL','PM1' )
    THEN 'PMC1'--10 Mar 2010
    ELSE 'PENMC'
    END,
    A.QWD_REVISIONNO = CASE v_DESIGNPARAMCODE01_TMP
    WHEN 'REST' THEN A.QWD_REVISIONNO + 1
    ELSE A.QWD_REVISIONNO
    END,
    A.QWD_MATQUOT_BASIS = v_DesignParamCode04;

    UNTESTED! but Try it :)
    UPDATE (SELECT a.*
              FROM CORM_QWD_QUOTE_WUTASK a, CORM_QMD_QUOTEMAT b
             WHERE (    A.QWD_ORDER_OU = B.QMD_ORDER_OU
                    AND A.QWD_ORDER_NO = B.QMD_ORDER_NO
                    AND A.QWD_AMEND_NO = B.QMD_AMEND_NO
                    AND A.QWD_REF_LINE_NO = B.QMD_REF_LINE_NO
                    AND A.QWD_TASK_LINE_NO = B.QMD_LINE_NO)
                   AND A.QWD_ORDER_OU = v_CUSORDEROU_TMP
                   AND A.QWD_ORDER_NO = v_CUSORDERNO_TMP
                   AND A.QWD_AMEND_NO = v_CoAmendmentNo_Tmp
                   AND ( (v_DesignParamCode04 = 'ACT'
                          AND A.QWD_QUOT_STATUS NOT IN ('PL', 'C'))
                        OR (v_DesignParamCode04 != 'ACT'
                            AND A.QWD_QUOT_STATUS NOT IN ('PENC', 'PL', 'C'))))
       SET A.QWD_QUOT_STATUS =
              CASE
                 WHEN A.QWD_QUOT_STATUS IN
                         ('PLM', 'PM', 'PMC1', 'PENC', 'PL', 'PM1') THEN
                    'PMC1'                                           --10 Mar 2010
                 ELSE
                    'PENMC'
              END,
           A.QWD_REVISIONNO =
              CASE v_DESIGNPARAMCODE01_TMP
                 WHEN 'REST' THEN A.QWD_REVISIONNO + 1
                 ELSE A.QWD_REVISIONNO
              END,
           A.QWD_MATQUOT_BASIS = v_DesignParamCode04;

  • Convert Sybase Update from query to Oracle PL/SQL

    Hi,
    I have a following Sybase Query for updating a table CRM_Report from another table CRM_Report1 r1, which I have to migrate PL/SQL.
    update CRM_Report
    set LT_MMT = r1.LT_MMT, ST_MMT = r1.ST_MMT,
    LT_FixedInc = r1.LT_FixedInc, ST_FixedInc = r1.ST_FixedInc,
    LT_CrdCLN = r1.LT_CrdCLN, ST_CrdCLN = r1.ST_CrdCLN,
    LT_Der = r1.LT_Der, ST_Der = r1.ST_Der,
    LT_FX = r1.LT_FX, ST_FX = r1.ST_FX,
    LT_CrdCDS = r1.LT_CrdCDS, ST_CrdCDS = r1.ST_CrdCDS
    from CRM_Report1 r1
    where r1.Location = CRM_Report.Location
    and r1.CountriesGrp_Id = CRM_Report.CountriesGrp_Id
    and r1.CountriesGrp_ShortName = CRM_Report.CountriesGrp_ShortName
    I used Oracle SQL Developer for query migration, but it doesn't seem to work
    Any Suggestions.

    In oracle
    update CRM_Report
       set (
            LT_MMT,
            ST_MMT,
            LT_FixedInc,
            ST_FixedInc,
            LT_CrdCLN,
            ST_CrdCLN,
            LT_Der,
            ST_Der,
            LT_FX,
            ST_FX,
            LT_CrdCDS,
            ST_CrdCDS
           ) =
           (SELECT r1.LT_MMT,
                       r1.ST_MMT,
                       r1.LT_FixedInc,
                       r1.ST_FixedInc,
                       r1.LT_CrdCLN,
                       r1.ST_CrdCLN,
                       r1.LT_Der,
                       r1.ST_Der,
                       r1.LT_FX,
                       r1.ST_FX,
                       r1.LT_CrdCDS,
                       r1.ST_CrdCDS
              from CRM_Report1 r1
          where r1.Location            = CRM_Report.Location
            and r1.CountriesGrp_Id       = CRM_Report.CountriesGrp_Id
            and r1.CountriesGrp_ShortName = CRM_Report.CountriesGrp_ShortName)
    WHERE EXISTS (SELECT NULL
              from CRM_Report1 r1
                where r1.Location            = CRM_Report.Location
               and r1.CountriesGrp_Id       = CRM_Report.CountriesGrp_Id
               and r1.CountriesGrp_ShortName = CRM_Report.CountriesGrp_ShortName)        

  • Can we use where clause in Update on Merge statement?

    Hi All,
    I tried to execute the following Merge Query:
    When this query is executed without ‘Where clause’ in Update statement its working fine. When executed with ‘Where clause’ it throwing the following error:
    ORA-00905: missing keyword.
    Following is the sample query which I tried to execute:
    MERGE INTO TABLE_NAME
    USING (SELECT COLUMN FORM TABLES)
    ON (CONDITION)
    WHEN MATCHED THEN
    UPDATE SET
         COLUMN UPATES
    WHERE CONDITION -- Can we use where clause here?
    WHEN NOT MATCHED THEN
    INSERT
    INSERT VALUES;
    Can some one help on this?
    Thanks in advance.
    Darius

    Yes:
    SQL> drop table emp1;
    Table dropped.
    SQL> create table emp1 as select * from emp where deptno = 30;
    Table created.
    SQL> update emp1 set sal = sal*2;
    6 rows updated.
    SQL> commit;
    Commit complete.
    SQL> select ename,sal from emp1;
    ENAME             SAL
    ALLEN            3200
    WARD             2500
    MARTIN           2500
    BLAKE            5700
    TURNER           3000
    JAMES            1900
    6 rows selected.
    SQL> MERGE INTO emp1
      2  USING(select * from emp) emp
      3  ON (emp1.empno = emp.empno)
      4  WHEN MATCHED THEN
      5  UPDATE SET sal = emp.sal WHERE ename = 'TURNER'
      6  WHEN NOT MATCHED THEN
      7  INSERT(ename,sal) VALUES(emp.ename,emp.sal);
    9 rows merged.
    SQL> select ename,sal from emp1;
    ENAME             SAL
    ALLEN            3200
    WARD             2500
    MARTIN           2500
    BLAKE            5700
    TURNER 1500
    JAMES            1900
    SMITH             800
    JONES            2975
    CLARK            2450
    SCOTT            3000
    KING             5000
    ENAME             SAL
    ADAMS            1100
    FORD             3000
    MILLER           1300
    14 rows selected.
    SQL> SY.

  • Need help in SQL Query: Update a row in a table & insert the same row into another table

    I want to update a row in a table say Table A and the updated row should be inserted into another table say Table B. I need to do it in a single SQL query and i don't want to do it in PL/SQL with triggers. And i tried with MERGE statement but its working with this scenario. (Note: I'm using Oracle Database 10g Enterprise Edition Release 10.2.0.1.0).
    Thanks in Advance.

    Using Sven's code as an example, you could save the updated row in a sql plus variable. (also untested):
    SQL> var v_id number
    update tableA  
    set colB='ABC' 
    where colC='XYZ' 
    returning id into :v_id;
    insert into table A_History (ID, colA, colB, ColC)  
    select id, ColA, ColB, ColC  
    from tableA  
    where id = :v_id;   

  • Query update using checkbox

    I have an admin page for a secure site where I am trying to
    add a function using a checkbox to create a true-false condition on
    each record in a database. What I have is a webpage with several
    records (pulled from the database using the cfquery loop, and
    assigned an ID that is stored in the database). Each record on the
    page has a checkbox; checked=true. What I want to do is make it
    possible to edit the checkboxes on the page, then have the user
    refresh the page using a submit button on the form, which will then
    update the database. However, I'm having a problem passing the
    value of the checkbox correctly to a cf page to run the update
    query and refresh the page.
    What values am I passing forward from a form using a
    checkbox, and what datatype should I be using to store that value
    in a SQL Server 2000 database? (Right now I'm testing with Access.)
    How do I convert the value from the checkbox to the true/false
    condition for the database to fit that datatype?
    My understanding is, the criterion for a checked box is
    checked="checked", and nothing if not checked. But how do I check
    to see if that value has changed? I'd rather do this without
    Javascript.
    Thanks!

    Tried it. Didn't work.
    Here's the code:
    <td><input type="checkbox" <cfif
    (#GetHeadlines.Show# EQ true)>checked="checked"</cfif>
    value="chk#getheadlines.id#" /></td>
    Here is also the code it's going to:
    <cfif isdefined ("form.value")>
    Value: #form.value#<br />
    </cfif>
    For good measure, I thought I'd include the form declaration:
    <form name="update" action="update_admin.cfm"
    method="post">
    This is just for testing purposes for now. However, I'm
    getting nothing on the back end page. So the value isn't being
    passed. I must be doing something wrong with the form, but
    what?

Maybe you are looking for

  • Portal Master-detail form how to auto assign detail record sequence number

    Portal Master-detail form how to auto assign detail record sequence number.Please help me?

  • Doubt in subpartitioning of a table

    hi gems...good evening.. I have a table which previously had only range partitions. Now I changed it to range-hash composite partitioning. There are 6 partition tablespaces namely TS_PART1, TS_PART2.....TS_PART 6. The default tablespace of the schema

  • Dynamic action in a report region in a master detail form

    hi I have created a master detail form , in which many validation etc is done ,the MASTER is a FORM  and DETAIL is a REPORT Now I am stuck up with the detail region .i.e report I have Line Detail where there are ITEMS such as SL NO: ,ITEM_ID , UOM (

  • Too Hot, Going Blank, and Click Noises

    I've read some of the previous posts on whining noises and noises in general, as well as those topics on heat. I've had my MacBookPro since Mid-April and everything was going fine until Mid-August. At some point, the computer started making whirring

  • Navigation blurs out/in background images

    Hi... At the risk of embarrassing myself, I'm adding my first post to this forum. Sorry, I'm a bit of a novice and what started out to be a simple background transition is proving to be a little harder than I first thought it would be. My problem is