MERGE statement and conditional insertions

Hello

With the help of 11.2.0.3 and have merge statement

want to use
When not matched and table.colvalue is not null
then insert

but doesn't like it.

A way to insert only if some attriburte is filled.

Thnaks

A way to insert only if some attriburte is filled.

insert into table_name select stmts

Merge to refer to this

http://docs.Oracle.com/CD/B19306_01/server.102/b14200/statements_9016.htm

Tags: Database

Similar Questions

  • Question about the MERGE statement

    Hi all

    I have a small question... I can post code, table creation, etc... but I think this question can be able to be simply answered, if I explain it. If you want me to zip codes, etc... then just ask and I'll do it.

    Here it goes:

    I have a set up merge statement, and I have two columns. One is named ADD_DT, and the other is called LST_UPD_DT.

    Update in the merge statement, the LST_UPD_DT column is updated with the SYSDATE.
    When it is inserted in the merge statement, the ADD_DT column is updated with the SYSDATE.

    So, here is my question:

    Regardless of whether or not the information is updated, the LST_UPD_DT updates the SYSDATE every time. Any advice on how to update the LST_UPD_DT column only if information is changed/updated, so that the information is not changed would be not updated by the SYSDATE? I hope that this question was not too complicated.

    Thank you all and if you want to see the code or examples of table... Please ask and I'll post one. I just thought that this may be able to meet without it.

    Hello

    991769 wrote:
    OK, here's what the table looks like:

    Thank you.

    CREATE TABLE TBL_SUPPLIERS
    (
    SUPP_CD                 VARCHAR2(40 CHAR),
    SUPP_NM                 VARCHAR2(255 CHAR),
    ADD_DT                  VARCHAR2(50 CHAR),
    LST_UPD_DT              VARCHAR2(50 CHAR))
    

    Do not use a VARCHAR2 column for date information. Use a DATE column.

    CREATE TABLE D_SUPPLIERS
    (
    SUPP_CD                 VARCHAR2(40 CHAR),
    SUPP_NM                 VARCHAR2(255 CHAR))
    
    INSERT INTO TBL_SUPPLIERS VALUES (1234, MINING, '03-26-2013 3:33:49 PM', '04-02-2013 9:04:52 AM');
    INSERT INTO TBL_SUPPLIERS VALUES (2345, ELECTRIC, '03-26-2013 3:33:49 PM', '04-02-2013 9:04:52 AM');
    INSERT INTO TBL_SUPPLIERS VALUES (3456, COAL, '03-26-2013 3:33:49 PM', '04-02-2013 9:04:52 AM');
    

    You want people to view the solutions that actually work? Please make sure that your own instructions will actually work. Test and fix your code before posting.
    All INSERT statements you posted fail; You seem to be missing single quotes around string literals. I think you meant:

    INSERT INTO TBL_SUPPLIERS VALUES (1234, 'MINING', '03-26-2013 3:33:49 PM', '04-02-2013 9:04:52 AM');
    ...
    

    Here's one way:

    MERGE INTO  tbl_suppliers     sm
    USING  (
               SELECT  d.*
            FROM              d_suppliers        d
            LEFT OUTER JOIN  tbl_suppliers  t  ON  t.supp_cd  = d.supp_cd
            WHERE   t.supp_cd                            IS NULL
            OR        DECODE (t.supp_nm, d.supp_nm, 0, 1) = 1
           )                       ds
    ON     (sm.supp_cd = ds.supp_cd)
        WHEN MATCHED THEN
            UPDATE SET
                sm.supp_nm = ds.supp_nm,
                sm.lst_upd_dt = SYSDATE
        WHEN NOT MATCHED THEN
            INSERT (sm.supp_cd, sm.supp_nm, sm.add_dt)
            VALUES
            (ds.supp_cd, ds.supp_nm, SYSDATE);
    
    SELECT     *
    FROM     tbl_suppliers
    ORDER BY     SUPP_CD;
    

    This can be more efficient, because it does not generate redo, or triggers, when two tables have exactly the same line.

  • insert/update County in the merge statement

    In the Merge statement, we can count the number of inserted rows and updated?

    ROWCOUNT SQL % simply returns the number of rows merged.

    It does not tell us the separately the line inserted and updated.

    # To insert the rowcount is the number of inserted rows for update is the number of rows updated, for the merger, that's the number of merged lines.

  • Under regions and conditional statements

    Greetings. Having a problem with conditional statements and subregions. With the help of apex 4.2

    I have a region (mutations) that has several items and a few buttons (button A, button B, etc.). I need to display conditionally button A. I have a sub region (People), which is a report of people deployed. I need a button to display the area of deployments, if there is no people in the report (People_ID is null) then the button will not appear. I tried to use a conditional, but I am not having any luck. Help, please. Thanks in advance.

    NewApexCoder wrote:
    I just tried to use a conditional button

    Condition Type: Point value / expression column 1 is NULL
    Expression 1: PEOPLE_ID

    This doesn't seem to work for me.

    No, it does not. (The inclusion of 'column' in this type of condition is inadequately documented. A "column" name only are referenced by such a condition, after presentation of a form in a table.)

    Use a Exists (SQL query returns at least one row) condition, based on the query in the subregion to report.

  • ignore the insert errors in a merge statement?

    Hi all

    I wonder if it is possible, somehow, to ignore the failings of the insert statement in a merge statement of bulk? The error encountered is the violation of a primary key. What is happening is that the different transactions share the same plsql procedure. Therefore, it could happen that different transactions will try to insert two rows with the same primary key.

    MERGE INTO table
    Using the collection
    WE (table.id = collection.id)
    WHEN MATCHED THEN
    UPDATE...
    WHEN NOT MATCHED THEN
    INSERT...-> it may fail for duplicates here

    The only solution would be to use 'updated massive day + bulk insert (ignore errors)' instead of a merger in bulk?

    Any help is very appreciated,
    WF

    What about using [DML Error Logging | http://www.oracle-base.com/articles/10g/DmlErrorLogging_10gR2.php#merge]?

  • Different result by using the MERGE statement

    I have 2 SQL statements:

    MERGE INTO PT_CQS_AGGR APC

    With the HELP of PT_CQS_AGGR_TEMP Lady

    WE (concat (concat(pca.from_city_id,pca.to_city_id), pca.query_timestamp_hh) = concat (concat(pcah.from_city_id,pcah.to_city_id), pcah.query_timestamp_hh))

    WHEN MATCHED THEN

    Setting a DAY SET pca.search_count = pca.search_count + pcah.search_count

    WHEN NOT MATCHED THEN

    VALUES of INSERTION (to_city_id, query_timestamp_hh, from_city_id, search_count) (pcah.from_city_id, pcah.to_city_id, pcah.query_timestamp_hh, pcah.search_count);

    AND

    MERGE INTO PT_CQS_AGGR APC

    With the HELP of PT_CQS_AGGR_TEMP Lady

    WE (pca.from_city_id = pcah.from_city_id AND pca.to_city_id = pcah.to_city_id AND pca.query_timestamp_hh = pcah.query_timestamp_hh)

    WHEN MATCHED THEN

    Setting a DAY SET pca.search_count = pca.search_count + pcah.search_count

    WHEN NOT MATCHED THEN

    VALUES of INSERTION (to_city_id, query_timestamp_hh, from_city_id, search_count) (pcah.from_city_id, pcah.to_city_id, pcah.query_timestamp_hh, pcah.search_count);

    First statement correctly the merged data, but use FULL TABLE SCANS, so it's rather slow. Second statement using a UNIQUE INDEX on the columns from_city_id, to_city_id, and query_timestamp_hh on the MAP of EXPLAIN, but during the execution of I've got ORA-00001: unique constraint (PODOWNER. IDX_CQS_AGGR_3COL) violated. What is the problem with the second statement - especially with this line:

    WE (pca.from_city_id = pcah.from_city_id AND pca.to_city_id = pcah.to_city_id AND pca.query_timestamp_hh = pcah.query_timestamp_hh)

    Can I use a more complex condition in the MERGE statement? Because it seems that not all the conditions have been taken...

    ???

    Select pcah.from_city_id, pcah.to_city_id, PT_CQS_AGGR_TEMP Lady pcah.query_timestamp_hh

    less

    Select pca.from_city_id, pca.to_city_id, pca.query_timestamp_hh PT_CQS_AGGR pca

    somewhere the conditions limiting the time.

    (or whatever the columns make up the stress of failing)

    In addition, select for each column in the constraint of failure where the column is null.  If one of these columns is null, equality fails, even if both are null, because null <> null.  So you will get a "no match" if all values are the same and it is set to null.

    Edit: Oh, slap forehead, that is why one works and the complete analysis.  As SomeoneElse said, it normalizes the type of data and concatenates, comparison null to no effect and refusing all usual index.

  • ORA-30926 - Merge statement

    Hi all

    I am facing a problem of failure to merge because of duplicate statement in the Source table. In a merge statement, what I understand is if the Update statement in which corresponding clause contains WHERE predicates, they are pushed upward to filter the lines of the clause?

    In order to understand, I tried to frame a test case to model how my real scenario is:

    create table tab_src (col1, col2 number number, number of col3, col4 varchar2 (5));
    create table tab_des (col1, col2 number number, number of col3, col4 varchar2 (5));

    insert into tab_src values (1, 1, 1, 'AAA');
    insert into tab_src values (1, 1, 0, "AAB");

    insert into tab_des values (1, 1, -1, null);

    explain plan for
    merge into tab_des d
    a_l'_aide_de)
    Select *.
    of tab_src
    where col3 is not null
    ) s
    on (d.col1 = s.col1
    and d.col2 = s.col2
    )
    When matched then
    update the value of col4 = s.col4
    where d.col3 is not null;

    Select *.
    table (dbms_xplan.display (null, null, 'ALL'));

    Hash value of plan: 3751341164

    --------------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

    --------------------------------------------------------------------------------

    |   0 | MERGE STATEMENT |         |     1.    60.     7 (15) | 00:00:01 |

    |   1.  MERGE | TAB_DES |       |       |            |          |

    |   2.   VIEW               |         |       |       |            |          |

    |*  3 |    HASH JOIN |         |     1.    98.     7 (15) | 00:00:01 |

    |   4.     TABLE ACCESS FULL | TAB_DES |     1.    55.     3 (0) | 00:00:01 |

    |*  5 |     TABLE ACCESS FULL | TAB_SRC |     2.    86.     3 (0) | 00:00:01 |

    --------------------------------------------------------------------------------

    Name of the query block / Alias object (identified by the operation identity card):

    -------------------------------------------------------------

    1 MRG$ 1

    3 SALT$ F5BB74E1

    4 SALT$ F5BB74E1 / D@SEL$1

    5. SALT$ F5BB74E1 / TAB_SRC@SEL$2

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    3 - access("D".") COL1 "=" TAB_SRC. " "" COL1 "AND

    "D"." COL2 "=" TAB_SRC. " ("" COL2 ")

    5 - filter ("COL3" IS NOT NULL)

    Projection of the column information (identified by the operation identity card):

    -----------------------------------------------------------

    1 SYSDEF [4], SYSDEF [32720], SYSDEF [1], SYSDEF [76], SYSDEF [32720]

    2 - « D ». "COL3" [NO.22], "S" "." " COL4 ' [VARCHAR2, 5].

    3. (#keys = 2) "D". "COL1" [NO.22], "TAB_SRC" "." " COL1 '[NUMBER, 22],

    "D"." COL2"[NO.22],"TAB_SRC ". ' COL2 '[NUMBER, 22],

    « D ». ROWID [ROWID, 10], "D". "COL4" [VARCHAR2, 5], "D" "." " COL3 '[NUMBER, 22],

    'TAB_SRC '. "COL4" [VARCHAR2, 5], 'COL3 '[NUMBER, 22] "

    4 - « D ». ROWID [ROWID, 10], "D". ' COL1 '[NUMBER, 22],

    "D"." COL2"[NO.22],"D ". "COL3" [NO.22], "D" "." " COL4 ' [VARCHAR2, 5].

    5. "TAB_SRC". "COL1" [NO.22], "TAB_SRC" "." " COL2 '[NUMBER, 22],

    'COL3' [NO.22], "TAB_SRC". "COL4" [VARCHAR2, 5].

    Note

    -----

    -dynamic sampling used for this statement

    The predicate information section made no reference to the column COL3 to the Destination table. Then it would be correct to conclude that the where predicates in the UPDATE clause will play no role in the identification of lines of data from source table/query?

    I use oracle 10.2.0.5.

    That's right, the where clauses are applied as the update is done, they will not be part of the condition WE which identifies the lines merge.  This is why you must make sure that your condition IT only joined the lines to merge and there are no duplicates.

  • need help with the Merge statement

    I'm on: Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production

    I'm currently an UPDATE statement and then it works and is accurate, it takes 30 minutes. I heard that MERGE
    can do the same thing and is just as accurate and much faster!

    Here's the query I want to convert into a MERGE INTO statement. I tried to do it myself, but I get errors and don't know simply, since it's new for me.

    Basically I want to update table your on a corresponding condition in the table tt for 2 columns (GTP and UPDATE_DT), for UPDATE_DT I want to insert the Date current system.
    UPDATE /*+ PARALLEL (16) */  OLDER_Table ta
    
    SET (ta.GTP, ta.UPDATE_DT) = 
    
                    (SELECT /*+ PARALLEL (16) */ tt.GTP, SYSDATE
                     FROM NEWER_Table tt
                     WHERE ta.cust_id = tt.cust_id
                     AND ta.STAMP_DATE = tt.STAMP_DATE
                     AND ROWNUM = 1)
    
                     WHERE EXISTS (SELECT 1
                                   FROM NEWER_Table tt
                                   WHERE ta.cust_id = tt.cust_id
                                   AND ta.STAMP_DATE = tt.STAMP_DATE
                                   AND (NVL(ta.GTP, 'X') != NVL(tt.GTP, 'X'))); 
    Thank you!

    Hello

    Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all of the tables involved.
    Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
    If you ask on a DML statement, such as UPDATE, CREATE TABLE and INSERT statements need to re - create the tables as they are before the DML, and results will be the content of the or the tables changed when it's all over.
    See the FAQ forum {message identifier: = 9360002}

    MERGE peut be much faster than update; Sometimes, there is no significant difference in speed.
    Tables in multiple situations like this, I've never seen a case where the MERGER has been slower than the UPDATE, even if the UPDATE is sometimes easier to code and just as fast.

    Maybe that's what you want:

    MERGE INTO  older_table            dst
    USING  (
               SELECT  n.cust_id
            ,        n.stamp_date
            ,        n.gtp
            ,        ROW_NUMBER () OVER ( PARTITION BY  n.cust_id
                                               ,           n.stamp_date
                             ORDER BY      n.gtp
                              )                    AS r_num
            FROM        newer_table  n
            JOIN        older_table     o  ON   n.cust_id     = o.cust_id
                                 AND     n.stamp_date     = o.stamp_date
                           AND     NVL ( n.gtp
                                    , 'X'
                                 )          != NVL ( o.gtp
                                                  , 'X'
                                              )
    
           )                 src
    ON     (    src.cust_id            = dst.cust_id
           AND  src.stamp_date     = dst.stamp_date
           AND  src.r_num            = 1
           )
    WHEN MATCHED THEN UPDATE
    SET    dst.gtp          = src.gtp
    ,      dst.update_date     = SYSDATE
    ;
    

    As I can't test it, I can't be sure.

  • Interrupted SQL statement and start several times with several SQL_EXEC_ID

    Hi all

    We meet a strange phenomenon, maybe someone can help.

    We see that sometimes, when our client runs a single statement, implemented Oracle to process the statement with a special SQL_EXEC_ID, but after a while stops and starts processing the statement along with different SQL_EXEC_ID. Then, after a while, it happens again - stop Oracle processes the statement and start from the beginning with the new SQL_EXEC_ID. This happens again and again until we kill all of the other sessions on the database (then it ends).

    What we see exactly: Client executes the statement (sql_id = "2tp7pz6yv87qp"). Monitor us v $ SQL_MONITOR and get this:

    SELECT Sql_id, sql_exec_id, to_char (SQL_EXEC_START, "HH24:MI:SS MON-DD-YYYY) SQL_EXEC_START, status OF V$ SQL_MONITOR where sql_id = '2tp7pz6yv87qp' ORDER BY SQL_EXEC_START DESC;

    2tp7pz6yv87qp 16777216 28 may 2015 07:19:14 the EXECUTION

    After a while check us again and see this:

    2tp7pz6yv87qp 16777217 28 may 2015 07:36:17 the EXECUTION

    2tp7pz6yv87qp 16777216 28 may 2015 07:19:14 FACT

    After a while, we see this:

    2tp7pz6yv87qp 16777219 28 may 2015 08:09:58 the EXECUTION

    2tp7pz6yv87qp 16777218 28 may 2015 07:53:37 FACT

    2tp7pz6yv87qp 16777217 28 may 2015 07:36:17 FACT

    2tp7pz6yv87qp 16777216 28 may 2015 07:19:14 FACT

    and so on — will happen again and again until we kill all of the other sessions in the database.

    When comparing the follow-up of the different SQL_EXEC_IDs SQL reports, we see that each of them did exactly the same job: used the same execution plan, beginning treatment she even read/wrote the same amount of e/s and each of them stopped at the same point during execution. You can see that for each SQL_EXEC_ID execution 'stops' in the middle and never reach the end of the plan. She always stops in the JOIN by HASH and never continue to the next steps in the implementation plan.

    When you look more deeply, we see in V$ ACTIVE_SESSION_HISTORY always last thing that happens for every SQL_EXEC_ID is HASH JOIN RIGHT OUTER (SQL_PLAN_OPERATION = HASH and SQL_PLAN_OPTIONS = RIGHT OUTER JOIN). Then comes the new SQL_EXEC_ID and it starts to do the same thing as the previous SQL_EXEC_ID did when it was launched.

    Kill all other sessions, run finally ends. We see that the final (successful) SQL_EXEC_ID work and completes his plan to run to completion.

    When executing the same single statement (when it comes to the single session in the database), it ends with a single SQL_EXEC_ID. Its SQL monitoring report looks like the final execution when the phenomenon occurs after killing all other sessions.

    -We checked that the customer executing the query only once. AWR also only shows simple execution of the query.

    -We have reproduced in many different clients (plus SQL, JDBC thin client OIC and DBMS_SCHEDULER job).

    -It has no PARALLEL in the query or table.

    -In this case for different statements (different INSERT-SELECT and MERGE instructions).

    -Version: Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    Does anyone have an idea?

    Finally found the root cause of the problem.

    This phenomenon occurs when the cursor of the active query being invalidated. This can occur in several scenarios, in our case, what happens when we work on a single partition (read or write) and perform DDL operations on different partitions of the same or the tables.

    Steps to reproduce:

    1 launch long command DML that affect the single partition

    2. in the course of executing this SQL, do one of the following values in a session different all 1 minute:

    2.1 do the indexes to a different partition unusable: ALTER TABLE X EDIT PARTITION Y UNUSABLE LOCAL INDEX

    2.2 rebuild the unusable index of different partition: ALTER TABLE X EDIT PARTITION Y REBUILD UNUSABLE LOCAL INDEX

    2.3 a partition different truncate

    Support of Oracle we were told that this problem is known and there are several requests for bugs and improvements thereon, for example this one:

    Bug 12905327 : TRUNCATE to an INVALID PARTITION TABLE UNNECESSARILY IMMEDIATELY all THE SLIDERS

    In our case (ETL process), we used to perform all these operations DDL and DML operations long (we work on different partitions in parallel). In order to solve, we have separated these operations to the different phases in our process and don't be DDL and DML operations at the same time more. This solved the problem for us.

  • Debugging this merge statement

    EMPL of MERGE IN one

    USING (SELECT *)

    T) b

    WE (a.empno = b.empno)

    WHEN MATCHED THEN

    UPDATE

    SET a.ename = b.ename, a.job = b.job,

    a.Mgr = b.mgr, a.hiredate = b.hiredate, a.sal = b.sal,

    a.comm b.com, a.deptno = b.deptno =

    WHEN NOT MATCHED THEN

    INSERT (a.empno, a.ename, a.job, a.mgr, a.hiredate, a.sal, a.comm,

    a.DEPTNO)

    VALUES (b.empno, b.ename, b.job, b.mgr, b.hiredate, b.sal, b.b.a., specialization

    b.DEPTNO);

    Note t is import table that has data of new employees and empl is the table that store data for all employees and it is the main table, above 2 tables are replica of scott.emp with data

    Problem when I'm executing the merge statement preceding the session is the gel

    Solution ?

    Perhaps another session has locked some rows in the emp table?

    Try

    select * from empl where empno in (select empno from t_imp) for update nowait;
    

    When you get an error such as ORA-00054, another session is locking of lines that you want to update.

    Hope that helps,

    dhalek

  • MERGE statement is increment the sequence. It problem?


    Hi all

    I use a merge statement to update thousands of data in a table. If the criteria does not match (WHEN NOT MATCHED) I wrote an insert statement that contains a reference to the sequence. And it works very well.

    My question is, will this increment also sequence even though it won't insert the statement in the script of fusion. I think it will be. Right?

    Say, I update 20K record will be the sequence also increment by 20 times k. If his past all work around.

    Thanks in advance.

    Here is a less effective solution to your problem that creates a function to get the value of the following sequence, but I agree with Justin cave that because of the cache you must lose the values.

    SQL > CREATE SEQUENCE s_emp;

    Order of creation.

    SQL > CREATE or REPLACE FUNCTION s_emp_nextval

    2 RETURN NUMBER

    3 AS

    4 v_nextval NUMBER;

    5 BEGIN

    6. SELECT s_emp.nextval

    7 INTO v_nextval

    8 DOUBLE;

    9 v_nextval of RETURN;

    10 END;

    11.

    The function is created.

    SQL > MERGE IN emp t (USING)

    2. SELECT empno, ename

    3 FROM emp) s

    4. WE (t.empno = s.empno)

    5. WHEN MATCHED THEN

    UPDATE 6

    7 SET t.ename = s.ename

    8 WHEN NOT MATCHED THEN

    9 INSERT (empno, ename)

    10 VALUES (s_emp_nextval, 'SMITH');

    14 lines merged.

    SQL > SELECT s_emp. NEXTVAL

    2 FROM dual;

    NEXTVAL

    ----------

    1

  • Error in the Merge statement using dblink

    Hello

    I am facing the following error when you use the merge statement using the dblink.

    ORA-02069: global_names must be set to true for this operation parameter.

    I can use the same dblink in my select insert and update statements but when I try to use merge then he invites the error said, is also not any syntax error as same statement can be used on the same tables of database instead of dblink.

    Please suggest any help will be much appreciated.

    Thanks in advance

    Hi Aqeel

    If insert and update statements work well through links db, then it should not be a problem with the merge statement. But if you are faced with the question, so please check the entire sql statement with tnsnames on both sides. Please share the tnsnames for the two dbs with dblink ddl.

    Concerning

    Jihane Narain Sylca

  • Return in the MERGE statement clause

    Hello

    I use Oracle 10 g Version

    I tried the code using UPDATE with return Clause & MERGER with return below Clause.

    I have not found ANY error while working with the UPDATE statement. Here is the code with the UPDATE statement

    DECLARE
       TYPE empno_list IS TABLE OF emp.empno%TYPE;
       vempno_list   empno_list;
    BEGIN
          UPDATE emp
             SET comm = 11
           WHERE deptno IN (SELECT deptno FROM dept)
       RETURNING empno
            BULK COLLECT INTO vempno_list;
       FOR i IN vempno_list.FIRST .. vempno_list.LAST
       LOOP
          DBMS_OUTPUT.put_line ('Values of EMP ' || vempno_list (i));
       END LOOP;
    END;   
    

    But PL/SQL error: ORA-00933: SQL not correctly completed command when you work with the MERGE statement

    declare 
     type empno_list  is  table of emp.empno%type;
     vempno_list empno_list;
    begin                
       merge into emp tgt 
          using dept src
            on (src.deptno =tgt.deptno)
            when matched then 
             update set tgt.comm=12
           returning tgt.empno bulk collect into vempno_list ;
           
            for i in vempno_list.first .. vempno_list.last loop
                    dbms_output.put_line('Values of EMP '||vempno_list(i) ) ;
            end loop;
    end;  
    

    Please suggest me

    Probably because BACK IN clause does not belong to the MERGE statement. It is available only for INSERT, UPDATE, and DELETE. Here's the quote from Oracle Documentation:

    The static method RETURNING INTO article belongs to a DELETE , INSERT , or UPDATE statement. The dynamic RETURNING INTO article belongs to a EXECUTE IMMEDIATE statement.

    And here is the link.

    Back IN the Clause

    It will be useful.

    Ishan

  • Merge statement

    Hi all

    I have a main table and a table of detail (the two are linked by a key (Param_id)).

    I just need to know is possible so that we can insert a record into the child table, whenever we are inserting record to master through a Merge statement.

    When matched

    Update...

    When not matched

    Insert...

    -An entry will be in the Master table, I want to know, is there a command by which I can make the entry in the child table, also

    Is no excuse for a double wire display.

    You have not 'right' to an answer. Respondents are volunteers who are free to choose what threads they meet.

    If someone won't respond to your thread creates a new thread with the same question will not help.

    And when someone mistreats forums by not following the guidelines of the forum makes it just AS likely that people will want to help you.

  • ORA-30926 on MERGE statement, occurs only with PARALLEL, success without PARALLEL hint hint.

    Hi Experts,

    I write under the MERGE statement. In this cardinality of the table_a table_b is 1:2. That is, each record of table_b corresponds to 2 records in table_a based on columns in CLAUSE.

    Well, this query throws below error.

    -Error-

    ORA-12801: error reported in the P011 parallel query server

    ORA-30926: failed to get a stable set of rows in the source tables

    However, the same statement runs successfully what tip PARALLEL is removed altogether. (There are no duplicates in table_b based on unity, group, loc columns.)

    Please sugget if anything look his place here or causes possible.

    -Request-

    MERGE / * + PARALLEL (8) * /.

    IN table_a a

    With the HELP of table_b b

    ON (a.unit = b.unit

    AND a.group = b.group

    AND a.loc = b.loc)

    WHEN MATCHED

    THEN UPDATE

    SET a.u_pushonly = b.u_pushonly

    a.u_seasonind = b.u_seasonind,

    a.eff = BOX

    WHEN b.u_season_start_dt <>TO_DATE('01/01/1970','DD/MM/YYYY')

    OR b.u_season_end_dt <>TO_DATE('01/01/1970','DD/MM/YYYY')

    OR b.u_pushonly = 1

    THEN more GRAND (NVL (b.u_assortment_start_dt, TO_DATE('01/01/1970','DD/MM/YYYY'))

    b.u_season_start_dt)

    Of OTHER NVL (b.u_assortment_start_dt, TO_DATE('01/01/1970','DD/MM/YYYY'))

    END;

    kendenny wrote:

    Fusion requires that columns be unique in both tables. Given that you only update was not insert is not put in correspondence, then you can use a single update statement.

    I don't think so, it requires only NEW data is unique. Informal argument: a single line in the new table can update several lines in the table of old, but you can not use several lines in the new table to update a single row in the old table.

    However, I wonder if something went wrong with the parallelism so that the lines with the same VALUES for the data (old) table_a has been distributed through many slaves, leading to several slaves, trying to update each on the other lines.  (I don't see how this could happen, but it's one of the problems with bugs - if she should not deceive you, it can be difficult to imagine how it's bad).

    To the OP - this sounds like something, you need to trigger an SR for (after a search of MOS).

    Concerning

    Jonathan Lewis

Maybe you are looking for