Get error in the merge statement

Version of Oracle, Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
Hi gurus

I am trying to perform the merge statement using the clause, but I get the error message, see below my sample data:

Examples of data

DROP TABLE OF BILLING;

DROP TABLE GROUP_MST;

DROP TABLE age_max;

CREATE ARRAY OF BILLING

(

BILLING_ID NUMBER (5),

RATE NUMBER (5),

MAXIMUM_AGE NUMBER (5),

package_id NUMBER (5)

);

INSERT

IN BILLING

(SELECT 11,1,10,100 FROM DUAL

UNION ALL

SELECT 12,2,15,100 FROM DUAL

UNION ALL

SELECT 13,3,20,100 FROM DUAL

);

CREATE TABLE GROUP_MST

(group_number NUMBER (5), package_id NUMBER (5))

);

INSERT INTO GROUP_MST

(SELECT DOUBLE 5 000 100

);

-------

CREATE TABLE AGE_MAX

(group_number NUMBER (5), max_age NUMBER (5))

);

INSERT

IN AGE_MAX

(SELECT 5000,60 FROM DUAL

);

Merge statement

MERGE INTO DRC USING billing

(WITH datum1 AS

(SELECT A.group_number,

b.billing_id,

b.rate,

b.maximum_age,

b.package_id

OF group_mst A,.

b billing

WHERE A.package_id = b.package_id

),

datum2 AS

(SELECT max_age, group_number FROM age_max

)

SELECT * FROM A, b WHERE A.group_number = b.group_number datum2 datum1

)

CBC ON (drc.billing_id = src.billing_id)

WHEN MATCHED THEN

UPDATE SET drc.maximum_age = src.max_age - 1;

Error

Error from the 33 in the command line:

MERGE INTO DRC USING billing

(WITH datum1 AS

(SELECT A.group_number,

b.billing_id,

b.rate,

b.maximum_age,

b.package_id

OF group_mst A,.

b billing

WHERE A.package_id = b.package_id

),

datum2 AS

(SELECT max_age, group_number FROM age_max

)

SELECT * FROM A, b WHERE A.group_number = b.group_number datum2 datum1

)

CBC ON (drc.billing_id = src.billing_id)

WHEN MATCHED THEN

UPDATE SET drc.maximum_age = src.max_age - 1

Error in the command line: 50 column: 1

Error report:

SQL error: ORA-00918: column ambiguously defined

00918 00000 - "ambiguously defined column.

* Cause:

* Action:

Thanks in advance

Concerning

Shu

WITH datum1 AS (SELECT A.group_number,

b.billing_id,

b.rate,

b.maximum_age,

b.package_id

OF group_mst A, b billing

WHERE A.package_id = b.package_id),

datum2 AS (SELECT max_age, group_number FROM age_max)

SELECT A.*, b.max_age, b.group_number as group_number_b - ERROR HERE

OF datum1 A, b datum2

WHERE A.group_number = b.group_number

Tags: Database

Similar Questions

  • 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

  • Defined column ambiguous error with the Merge statement

    Hi guys,.
    I get the ' Error (136,4): PL/SQL: ORA-00918: column ambiguously defined "error with the following query of fusion,
    MERGE INTO Inv_Stk_Trns_Tail a
       USING (SELECT b.*, c.*
       FROM OLR b ,Inv_Stk_Trns_Tail c 
       WHERE b.Trn_Type <> '0'
         AND b.VoucherType IS NOT NULL
         AND b.VoucherType = 'SF'
         AND b.Item_Code = c.Item_Code
         AND c.PROPERTY = 0) src
       ON (a.Sl_No = src.Sl_No and a.Ref_No = src.Ref_No )
       WHEN MATCHED THEN UPDATE SET Item_Avg_Ppr = src.Opn_Avg_Cost,
                                    Rate_Bc = src.Opn_Avg_Cost;
    I tried to solve the problem in a lot of ways, but no use. Please help me solve this problem. If you want more details, I'll give you.
    Thank you
    RAM

    SELECT B.*, c.

    Try all the (necessary) columns on the code and the name of each column a unique alias.

  • Person registering in the Merge statement error!

    Is it possible to save indivudual error in the MERGE statement (Update / Insert).
    I'm unable to save these error. instead of MERGING, if I update the table in the cursor loop then I am able to record the individual error but the process takes time.
    Thanks in advance.
    Deba

    Hi Deba,

    Logging of DML errors:

    SQL> create table tab1 (x number(1));
    
    Table created.
    
    SQL> exec dbms_errlog.create_error_log('tab1')
    
    PL/SQL procedure successfully completed.
    
    SQL>
    SQL> merge into tab1 t
      2        using (select 1 x from dual union all
      3               select 112 x from dual) s
      4  on (t.x = s.x)
      5  when not matched
      6  then insert (x) values (s.x)
      7  log errors into err$_tab1 reject limit unlimited;
    
    1 row merged.
    
    SQL>
    SQL> COL x for 9999
    SQL> select * from tab1;
    
        X
    -----
        1
    
    SQL> COL x for a4
    SQL> select ora_err_number$, X from err$_tab1;
    
    ORA_ERR_NUMBER$ X
    --------------- ----
               1438 112
    
    SQL>
    

    Concerning
    Peter

  • I try to copy a CD but get an error in the column State of Rip. Has not changed any option, as I just ripped a CD yesterday. HELP PLEASE!

    I have NEED of HELP PLEASE I am trying to copy a CD but get an error in the column State of Rip. Has not changed any option, as I just ripped a CD yesterday.  HELP PLEASE!

    Hello

    1. What is the exact error message?

    2. is the issue specific to this particular CD/DVD?

    3 did you changes to the computer, before the show?

    Method 1:

    Run the Windows Media Player settings troubleshooter.

    Open the troubleshooting Windows Media Player settings Troubleshooter

    Method 2:

    Change the settings for the extraction of music and the audit.

    Change settings for ripping

  • ORA 22813 in the merge statement

    Hi the gems... Good afternoon...

    My version of the database is 11.2.0.1.0 Solaris 64-bit OS.

    I am facing a ' ORA-22813: value of the operand exceeds the limits of the system "during the execution of a procedure.
    I used loggers and found that it is getting failed in a MERGE statement.

    This merge statement is used to merge a table with a collection. the code is as below:
    MERGE /*+ INDEX(P BALANCE_HISTORIC_INDEX) */
        INTO BALANCE_HOLD_HISTORIC P
        USING TABLE(GET_BALANCE_HIST(V_MERGE_REC)) M
        ON (P.CUSTOMER_ID = M.CUSTOMER_ID AND P.BOOK_ID = M.BOOK_ID AND P.PRODUCT_ID = M.PRODUCT_ID AND P.SUB_BOOK_ID = M.SUB_BOOK_ID AND)
        WHEN MATCHED THEN
          UPDATE
             <set .....>
        WHEN NOT MATCHED THEN
          INSERT<.....>
    Function GET_BALANCE_HIST (V_MERGE_REC) parameter is an array type.
    Now GET_BALANCE_HIST (V_MERGE_REC) is a function in the pipeline and we used that because the V_MERGE_REC collection can become huge with data.

    This process worked very well since the beginning, but since yesterday, it was constantly throwing 22813 ORA error in this line.

    Help, please... Thanks in advance...

    Gogol wrote:
    The code flow is as below:

    There is a sql query, the output is a set of some several lakes of records. Now we take the result of the sql query in a collection with a limit of 1000 (FETCH cur_sql COLLECT LOOSE v_balance_rec LIMIT 1000). Then we do a lot of processing, the calculation of this collection.

    After the treatment and calculation, we are filling another collection this collection transformed (V_BALANCE_REC) (V_MERGE_REC). Thus, if the loop iterates for 1000 times, then the V_MERGE_REC is filled with records of 1000 * 500 = 500000 processed.

    And then we go to this huge V_MERGE_REC collection as a parameter to this function.

    Don't know what are the Lakes. Please use International English.

    Why can't do you math in a SQL query?

    If it's really too hard to do in SQL (SQL queries can perform a treatment fairly complex), then I would look to Scripture
    results of a table and use it.

  • 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.

  • 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

  • Getting errors on the 3 Windows updates: 2699988, 270162, 2685939. On the first try error codes were 0 x 80246007 and 0x8007010B

    Getting errors on the 3 Windows updates: 2699988, 270162, 2685939.  On the first try error codes have been 0 x 80246007 for all 3, try subsequent was 0x8007010B.

    Configuration is Windows XP SP3 with MSIE6 (test the system reads old browser).  Any suggestions?

    Original title: get errors on the 3 Windows updates

    Maybe: http://support.microsoft.com/kb/958042

    When you try to install the updates on the Windows Update Web site or the Microsoft Update Web site, you may receive a "0 x 80246007" error code

  • Get errors for the user input data filter no KB 911895 HID

    OT: iI have windows xp S/P 3 installed also apple i pad I get errors for the user input data filter no KB 911895 HID
    What should I do to get rid of this popup that wizzard windows keeps giving me?

    Hi Graybeard,

    What is the exact error message you get?

    HID Non-User Input data filter is an optional update. I suggest you try the steps from the following link:

    The screen saver does not start after the installation of a wireless pointing device
    http://support.Microsoft.com/kb/913405

    What version of the operating system Windows am I running?
    http://Windows.Microsoft.com/en-us/Windows7/help/which-version-of-the-Windows-operating-system-am-i-running

    Troubleshooting Windows Update or Microsoft Update when you are repeatedly offered an update
    http://support.Microsoft.com/kb/910339

  • I can't send an e-mail as a group, with or without an attachment, I always get error 0x800CCC0B the message, I have outlook express.

    cannot send error 0x800CCC0B group

    I can't send an e-mail as a group, with or without an attachment, I always get error 0x800CCC0B the message, I have outlook express (not sure which version) under XP, I used to be able to send a group with 500 more emails in it, I tried to narrow the group to 200, but it makes no difference can anyone help?
    Check out this link. Apparently there is a max of 100 recipients simultaneously and they also will disable your account temporarily if you try many times.
     
     
  • I recently upgraded to Photoshop cc (2015) and Windows 10.  Now I get error messages - "the extension of com.adobe.preview.loader could not be loaded because it was not properly signed.  And when I try to open a dng file, it comes up with "cannot be compl

    I recently upgraded to Photoshop cc (2015) and Windows 10.  Now I get error messages - "the extension of com.adobe.preview.loader could not be loaded because it was not properly signed.

    When I try to open a dng file, it comes up with "could not complete your request because it is not the right type of doc.  Now I have "expansion of libraries could not be loaded because it was not properly signed.

    Any help would be greatly appreciated.  The program worked perfectly in the past.

    I contacted Support Adobe this morning, and they were able to solve the problem.  It was difficult.

  • I downloaded the latest version of the DNG Converter Camera Raw version 9.1.1 for windows. However, I get error install the update saying "error opening file for writing. Also on my help menu updates is not active?

    I downloaded the latest version of the DNG Converter Camera Raw version 9.1.1 for windows. However, I get error install the update saying "error opening file for writing. Also on my help menu updates is not active?

    If the installation program itself fails to open and run. Download it again maybe your current download is corrupted. Also, what OS you are using and you are an administrator with permission to install.

  • Lightroom starts but then I get "error reading the preview cache. LR needs to stop smoking.  Will try next time it starts. I restart from scratch and the same thing happens.  Help please!

    Lightroom starts but then I get "error reading the preview cache. LR needs to stop smoking.  Will try next time it starts. I restart from scratch and the same thing happens.  Help please!

    In the same folder that your catalog file is stored in, there is a subfolder whose name ends with Previews.LRDATA. Delete this subfolder whose name ends with Previews.LRDATA. Do not remove anything else.

  • 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.

Maybe you are looking for