Oracle 10: merge into problem

From ext_mitglied I want to insert ort, plz,strasse into tbl_adresse. And I will do it with merge. The values are currently not existing in tbl_adresse. But Oracle says the unique constraint uq_adresse is violated.
I don't see where the fault is.?
CREATE TABLE tbl_adresse
(o_id number(15) NOT NULL,
ort varchar2(30) DEFAULT 'Berlin' NOT NULL,
plz number(5) NOT NULL,
strasse varchar2(30) NOT NULL,
CONSTRAINT pk_adresse PRIMARY KEY (o_id),
CONSTRAINT chk_plz CHECK (plz >= 10000),
CONSTRAINT uq_adresse UNIQUE (ort, plz, strasse)
CREATE TABLE ext_mitglied
m_id number(15),
ort varchar2(30),
plz number(5),
strasse varchar2(30),
m_anrede varchar2(10),
m_vorname varchar2(30),
m_nachname varchar2(30),
kto_nr number(10),
blz number(10),
geb_datum date,
tel_nr varchar2(30),
beginn date,
ende date,
bezahlt number(1)
MERGE INTO tbl_adresse a
USING ext_mitglied ex
ON ((ex.ort=a.ort) AND (ex.plz=a.plz) AND (ex.strasse=a.strasse))
WHEN NOT MATCHED
THEN INSERT ( a.o_id, a.ort, a.plz, a.strasse)
VALUES( seq_ort.NEXTVAL, ex.ort, ex.plz, ex.strasse );

Oracle 10 is what? Is that 10.1.0.3, 10.2.0.1, 10.2.0.4 or something else?
Nowhere in what you posted is an error message either so there is no basis upon which to advise you other than to say that I personally stay away from MERGE statements like they are a plague.
Please provide DDL for the table, unique indexes if they exist, and constraints.
And run your statement again.
Then use a SELECT COUNT(*) to prove no record exists that with your merge statement won't create a violation of the named constraint.
Then take all of it and copy it to the forum without editing so we can read it.
Also please read the FAQ before you do and learn to use tags to make your listings understandable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • Problem with merge into

    Hi All!
    Following statement give me an error ORA-00904: Invalid column name in the string:
    on (Mirror.ARCH_FLAG=qt.ARCH_FLAG and Mirror.CREDIT_HEADER_ID=qt.CREDIT_HEADER_ID)
    merge into CREDIT_HEADER_P Mirror
    using (select
    CREDIT_HEADER_ID,
    PO_DATE,
    HP_RECEIVED_DATE,
    PDA_ID,
    CUSTOMER_BASE_NR,
    CREDIT_TYPE,
    CREDIT_CURRENCY,
    CLAIM_SUBTYPE_ABREV,
    CUST_PO_NO,
    BILLING_NO,
    OMS_START_SECTION_NO,
    OMS_END_SECTION_NO,
    OMS_SHIP_VIA,
    OMS_CHANGE_REASON_CODE,
    CUST_COMMENT,
    SPECIAL_INSTRUCTIONS,
    CASH_DISCOUNT,
    TARGET_SYSTEM,
    DATE_SENT_TO_TARGET_SYSTEM,
    ARCH_FLAG,
    RECORD_EXTRACTION_DATE,
    LAST_MOD_DATE
    from INC_CREDIT_HEADER_P) qt
    on (Mirror.ARCH_FLAG = qt.ARCH_FLAG and Mirror.CREDIT_HEADER_ID = qt.CREDIT_HEADER_ID)
    when matched then
    update
    set      Mirror.CREDIT_HEADER_ID=qt.CREDIT_HEADER_ID,
         Mirror.PO_DATE=qt.PO_DATE,
         Mirror.HP_RECEIVED_DATE=qt.HP_RECEIVED_DATE,
         Mirror.PDA_ID=qt.PDA_ID,
         Mirror.CUSTOMER_BASE_NR=qt.CUSTOMER_BASE_NR,
         Mirror.CREDIT_TYPE=qt.CREDIT_TYPE,
         Mirror.CREDIT_CURRENCY=qt.CREDIT_CURRENCY,
         Mirror.CLAIM_SUBTYPE_ABREV=qt.CLAIM_SUBTYPE_ABREV,
         Mirror.CUST_PO_NO=qt.CUST_PO_NO,
         Mirror.BILLING_NO=qt.BILLING_NO,
         Mirror.OMS_START_SECTION_NO=qt.OMS_START_SECTION_NO,
         Mirror.OMS_END_SECTION_NO=qt.OMS_END_SECTION_NO,
         Mirror.OMS_SHIP_VIA=qt.OMS_SHIP_VIA,
         Mirror.OMS_CHANGE_REASON_CODE=qt.OMS_CHANGE_REASON_CODE,
         Mirror.CUST_COMMENT=qt.CUST_COMMENT,
         Mirror.SPECIAL_INSTRUCTIONS=qt.SPECIAL_INSTRUCTIONS,
         Mirror.CASH_DISCOUNT=qt.CASH_DISCOUNT,
         Mirror.TARGET_SYSTEM=qt.TARGET_SYSTEM,
         Mirror.DATE_SENT_TO_TARGET_SYSTEM=qt.DATE_SENT_TO_TARGET_SYSTEM,
         Mirror.ARCH_FLAG=qt.ARCH_FLAG,
         Mirror.RECORD_EXTRACTION_DATE=qt.RECORD_EXTRACTION_DATE,
         Mirror.LAST_MOD_DATE=qt.LAST_MOD_DATE,
         Mirror.RECORD_STATUS='M'
    when not matched then
    insert (
    Mirror.CREDIT_HEADER_ID,
    Mirror.PO_DATE,
    Mirror.HP_RECEIVED_DATE,
    Mirror.PDA_ID,
    Mirror.CUSTOMER_BASE_NR,
    Mirror.CREDIT_TYPE,
    Mirror.CREDIT_CURRENCY,
    Mirror.CLAIM_SUBTYPE_ABREV,
    Mirror.CUST_PO_NO,
    Mirror.BILLING_NO,
    Mirror.OMS_START_SECTION_NO,
    Mirror.OMS_END_SECTION_NO,
    Mirror.OMS_SHIP_VIA,
    Mirror.OMS_CHANGE_REASON_CODE,
    Mirror.CUST_COMMENT,
    Mirror.SPECIAL_INSTRUCTIONS,
    Mirror.CASH_DISCOUNT,
    Mirror.TARGET_SYSTEM,
    Mirror.DATE_SENT_TO_TARGET_SYSTEM,
    Mirror.ARCH_FLAG,
    Mirror.RECORD_EXTRACTION_DATE,
    Mirror.LAST_MOD_DATE
    values (
    qt.CREDIT_HEADER_ID,
    qt.PO_DATE,
    qt.HP_RECEIVED_DATE,
    qt.PDA_ID,
    qt.CUSTOMER_BASE_NR,
    qt.CREDIT_TYPE,
    qt.CREDIT_CURRENCY,
    qt.CLAIM_SUBTYPE_ABREV,
    qt.CUST_PO_NO,
    qt.BILLING_NO,
    qt.OMS_START_SECTION_NO,
    qt.OMS_END_SECTION_NO,
    qt.OMS_SHIP_VIA,
    qt.OMS_CHANGE_REASON_CODE,
    qt.CUST_COMMENT,
    qt.SPECIAL_INSTRUCTIONS,
    qt.CASH_DISCOUNT,
    qt.TARGET_SYSTEM,
    qt.DATE_SENT_TO_TARGET_SYSTEM,
    qt.ARCH_FLAG,
    qt.RECORD_EXTRACTION_DATE,
    qt.LAST_MOD_DATE
    But! If I do:
    select Mirror.CREDIT_HEADER_ID
    from CREDIT_HEADER_P Mirror
    or
    select Mirror.ARCH_FLAG
    from CREDIT_HEADER_P Mirror
    I don't get any error. I copied (not entered new!) The column and table name from the statement above! If I submit Mirror.ARCH_FLAG and Mirror.CREDIT_HEADER_ID with 1, it works also. Any ideas?
    Regards,
    Andrej

    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_915a.htm#2080942
    You cannot specify DEFAULT when updating a view.
    You cannot update a column that is referenced in the ON condition clause. Problem is you use ARCH_FLAG and CREDIT_HEADER_ID in ON clause -
    on (Mirror.ARCH_FLAG = qt.ARCH_FLAG and Mirror.CREDIT_HEADER_ID = qt.CREDIT_HEADER_ID)
    and try to update them:
    set Mirror.CREDIT_HEADER_ID=qt.CREDIT_HEADER_ID,
    Mirror.ARCH_FLAG=qt.ARCH_FLAG,
    It violates the deterministic.
    Rgds.

  • My latest pano photo have missing landscape. Some of the photos are merged into one. I can provide the examples. What could cause this problem on a new 5C?

    My latest pano photo have missing landscape. Some of the photos are merged into one. I can provide the examples. What could cause this problem on a new 5C?

    Thanks for the input. I was finally able to find some test conditions that duplicated the problem, and it is either that or some other out-of-spec diffraction distortion.  So I sent it off for repair.

  • Problem with Merge into stmt

    Dears,
    I m using 10g XE.
    I am using merge into stmt, to inesrt non matched records and to update matched records with respect to primary key.
    I have two uers in oracle. (TMP and REAL)
    I have n number of tables with same definition in both users.
    I will always merge all the tables into "REAL" from TMP uesr
    Each and very table may contain more than 200000 records.
    while merging some of the records got deleted from the REAL user which already available in REAL user.
    i.e records available in TEMP.A is not available in REAL.A
    if i re rerun the merge qry once again, the missing records inserted into REAL.A
    how it happens? is ther is any bug with merge into stmt while processing huge amount of rows.
    Sample Qry:
    MERGE INTO REAL.med_stock_sales B
    USING (
    SELECT 1 AS RETAIL_OUTLET_ID,mss_id,MSS_ITEMCODE,MSS_TRAN_DATE,MSS_TRAN_TYPE,MSS_REF_NO,MSS_TRANS_QTY,MSS_FREE_QTY,MSS_PUR_RATE,MSS_SELLING,MSS_TAG,MSS_BNO,MSS_CAT1,MSS_CAT2,MSS_CAT3,MSS_CAT4,MSS_CAT5,MSS_CAT6,MSS_CAT7,MSS_CAT8,MSS_CAT9,MSS_CAT10,MSS_compid,MSS_diviid,MSS_locaid,TS,MSS_BAGS FROM TMP.med_stock_sales) E
    ON (B.RETAIL_OUTLET_ID = E.RETAIL_OUTLET_ID AND B.MSS_ID = E.mss_id )
    WHEN MATCHED THEN
    UPDATE SET B.MSS_ITEMCODE = E.MSS_ITEMCODE , B.MSS_TRAN_DATE = E.MSS_TRAN_DATE , B.MSS_TRAN_TYPE = E.MSS_TRAN_TYPE , B.MSS_REF_NO = E.MSS_REF_NO , B.MSS_TRANS_QTY = E.MSS_TRANS_QTY , B.MSS_FREE_QTY = E.MSS_FREE_QTY , B.MSS_PUR_RATE = E.MSS_PUR_RATE , B.MSS_SELLING = E.MSS_SELLING , B.MSS_TAG = E.MSS_TAG , B.MSS_BNO = E.MSS_BNO , B.MSS_CAT1 = E.MSS_CAT1 , B.MSS_CAT2 = E.MSS_CAT2 , B.MSS_CAT3 = E.MSS_CAT3 , B.MSS_CAT4 = E.MSS_CAT4 , B.MSS_CAT5 = E.MSS_CAT5 , B.MSS_CAT6 = E.MSS_CAT6 , B.MSS_CAT7 = E.MSS_CAT7 , B.MSS_CAT8 = E.MSS_CAT8 , B.MSS_CAT9 = E.MSS_CAT9 , B.MSS_CAT10 = E.MSS_CAT10 , B.MSS_compid = E.MSS_compid , B.MSS_diviid = E.MSS_diviid , B.MSS_locaid = E.MSS_locaid , B.TS = E.TS , B.MSS_BAGS = E.MSS_BAGS
    WHEN NOT MATCHED THEN
    INSERT (B.RETAIL_OUTLET_ID , B.MSS_ID , B.MSS_ITEMCODE , B.MSS_TRAN_DATE , B.MSS_TRAN_TYPE , B.MSS_REF_NO , B.MSS_TRANS_QTY , B.MSS_FREE_QTY , B.MSS_PUR_RATE , B.MSS_SELLING , B.MSS_TAG , B.MSS_BNO , B.MSS_CAT1 , B.MSS_CAT2 , B.MSS_CAT3 , B.MSS_CAT4 , B.MSS_CAT5 , B.MSS_CAT6 , B.MSS_CAT7 , B.MSS_CAT8 , B.MSS_CAT9 , B.MSS_CAT10 , B.MSS_compid , B.MSS_diviid , B.MSS_locaid , B.TS , B.MSS_BAGS )
    VALUES (E.RETAIL_OUTLET_ID , E.mss_id , E.MSS_ITEMCODE , E.MSS_TRAN_DATE , E.MSS_TRAN_TYPE , E.MSS_REF_NO , E.MSS_TRANS_QTY , E.MSS_FREE_QTY , E.MSS_PUR_RATE , E.MSS_SELLING , E.MSS_TAG , E.MSS_BNO , E.MSS_CAT1 , E.MSS_CAT2 , E.MSS_CAT3 , E.MSS_CAT4 , E.MSS_CAT5 , E.MSS_CAT6 , E.MSS_CAT7 , E.MSS_CAT8 , E.MSS_CAT9 , E.MSS_CAT10 , E.MSS_compid , E.MSS_diviid , E.MSS_locaid , E.TS , E.MSS_BAGS )

    Hi
    if i re rerun the merge qry once again, the missing records inserted into REAL.AThat's exactly what you would expect. Your SQL will insert into REAL.med_stock_sales any records that are in the TEMP table but not in the REAL table - assuming the primary key is (RETAIL_OUTLET_ID, MSS_ID). So if you delete records from REAL, they will keep being repopulated from TEMP - and matching records in REAL will be updated from TEMP
    If you want to be able to delete records from REAL without this happening, you have a couple of options:
    1) when you delete from REAL, also delete from TEMP (eg using a trigger). This is simplest.
    2) when you delete from REAL, don't actually delete, just update a DELETED_YN flag
    3) when you delete from REAL, add the primary key to a DELETED_STOCK table. Then change your merge to exclude "deleted" records
    MERGE INTO REAL.med_stock_sales B
    USING (
    SELECT 1 AS RETAIL_OUTLET_ID,mss_id,MSS_ITEMCODE
       ,MSS_TRAN_DATE,MSS_TRAN_TYPE,MSS_REF_NO,MSS_TRANS_QTY,MSS_FREE_QTY
       ,MSS_PUR_RATE,MSS_SELLING,MSS_TAG,MSS_BNO
       ,MSS_CAT1,MSS_CAT2,MSS_CAT3,MSS_CAT4,MSS_CAT5,MSS_CAT6,MSS_CAT7,MSS_CAT8,MSS_CAT9,MSS_CAT10
       ,MSS_compid,MSS_diviid,MSS_locaid,TS,MSS_BAGS
    FROM TMP.med_stock_sales ss
    WHERE not exists (
        SELECT 1 FROM REAL.DELETED_STOCK ds
        WHERE ds.RETAIL_OUTLET_ID = ss.RETAIL_OUTLET_ID AND ds.MSS_ID = ss.mss_id
    ) E
    ON (B.RETAIL_OUTLET_ID = E.RETAIL_OUTLET_ID AND B.MSS_ID = E.mss_id )
    WHEN MATCHED THEN ...Hope that helps
    Regards Nigel

  • Oracle 11g - Merge PL/SQL issue - Same code work in Oracle10g

    Below PL/SQL block stop working after Oracle11g upgrade, working fine in Oracle10g
    CREATE TABLE TMP_TABLE1 (P_PROVIDER NUMBER, P_ID NUMBER);
    CREATE TABLE TMP_TABLE2 (COL1 NUMBER, COL2 NUMBER);
    CREATE TABLE TMP_TABLE3 (COL3 NUMBER, COL4 NUMBER);
    BEGIN
    FOR i IN (SELECT p_provider p_provider, p_id p_id FROM tmp_table1)
    LOOP
    MERGE INTO TMP_TABLE2 T
    USING ( SELECT I.P_PROVIDER P_PROVIDER,
    I.P_ID P_ID FROM DUAL) DDD
    ON (T.COL1= DDD.P_PROVIDER AND T.COL2 = DDD.P_ID)
    WHEN NOT MATCHED THEN
    INSERT (COL1, COL2) VALUES (1, (SELECT x.COL4 FROM TMP_TABLE3 x WHERE x.COL4 = DDD.P_ID));
    END LOOP;
    END;
    Oracle 10g Version:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    Oracle 11g Version:
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    PL/SQL Release 11.2.0.2.0 - Production
    CORE 11.2.0.2.0 Production
    TNS for Linux: Version 11.2.0.2.0 - Production
    NLSRTL Version 11.2.0.2.0 – Production
    Oracle11 g Error:
    Error at line 5
    ORA-06550: line 11, column 93:
    PL/SQL: ORA-00904: "DDD"."P_ID": invalid identifier
    ORA-06550: line 5, column 7:
    PL/SQL: SQL Statement ignored
    Script Terminated on line 5.
    Is there any patch/work around in Oracle 11g?
    Please advice
    Thank you
    Raj

    We had a similar issue when our organization upgraded to 11gR2.
    It looks like it boils down to a change Oracle made in regards to how it works with correlated subqueries within an insert statement.
    Anyway, this thread has a little more information:
    Merge Command in 10g vs 11g
    And it says to look at Metalink note 1109983.1 (which I can't seem to find).
    Anyway, a workaround in thread is suggests (which worked for us) to wrap the insert subquery around a dummy decode clause, and oddly it will work.
    eg:
    INSERT (COL1, COL2) VALUES (1, (decode(1,1,(SELECT x.COL4 FROM TMP_TABLE3 x WHERE x.COL4 = DDD.P_ID)) ) ) ;
    Quite a kludge, but at least it is an immediate fix to the problem, without having to rewrite anything.

  • Primary key failure with merge into...should not happen

    I get primary key constraint fail on this MERGE INTO sql.
    Why? Shouldn't the merge into take care of this?
    ORA-00001: unique constraint (NCSL.SYS_C001568) violated
    MERGE INTO SessionTbl2 thistbl
    USING
      (SELECT 'b2cdd2f30b786c329ad2f8d04d0e79e9' sessionid FROM dual) thistbl2
      ON (thistbl2.sessionid = thistbl.sessionid AND thistbl.varname=:varname)
    WHEN MATCHED THEN
      UPDATE SET thistbl.varvalue=:variablevalue,
      thistbl.only_on_page=:onlyonpage,
      thistbl.expire_tstamp=:expire_tstamp,
      thistbl.inactivity_timeout=:inactivity_timeout,
      thistbl.readonly=:readonly
    WHEN NOT MATCHED THEN
      INSERT (sessionid,varname,varvalue,tstamp,
      only_on_page,expire_tstamp,inactivity_timeout,
      readonly)          
      VALUES
      (:cacheidval,:varname,:variablevalue,:nowts,
      :onlyonpage,:expire_tstamp,:inactivity_timeout,
      :readonly)

    As you say, this should not give a problem then, but the only way to be sure the system is doing what you believe it should do is to use the same variables in the test and in the insert statement. The bind variable depends on the programming language you use and may pass something else than the string that oracle generates in the select from dual. I do not say it will be as such, I just want to make sure that this is not the problem. I have seen things like this before and you keep on looking in the wrong direction for a solution.
    Peter

  • MERGE INTO and CROSS JOIN

    Hello Guys,
    I have a bit of trouble understanding the MERGE I have written here.
    All the code executes without errors. As far as I see,
    the below MERGE SELECT is a Cartesian product/cross join and I remember that is not
    good. The ON (join condition) seems to be only for the merge into table (T_CLAIMS_BB) and
    the table that comes from the select (d).
    merge into T_CLAIMS_BB t
    using
    SELECT sch_vt.SCH#,vert.CNO,vers.SubCNo,regv.ReturnNo,regv.SndReturnNo,sch_vt.MainProd,sch_vt.Prod
    FROM mainschema.TCONTRACT vert, mainschema.TVERSCONTRACT vers, commonschema.VC_REGVEREINB regv, myschema.T_CLAIMS_VT sch_vt
    ) d
    ON (
    t.sch# = d.sch# AND
    SUBSTR(UPPER(t.BOOKINGTEXT),1,2) = d.SndReturnNo AND d.SubCNo IS NULL
    ) -- Join
    when matched then
    update
    set t.CNO = 'a',
    t.ReturnNo = 'a',
    t.MainProd = 'b',
    t.Prod = 'c';
    I wonder now, what is the advantage of using MERGE in my case - if there is one.
    Finally I want to demonstrate how the whole thing would look without a MERGE:
    SELECT vers.* FROM TVERSCONTRACT vers
    LEFT OUTER JOIN myschema.T_CLAIMS_BB sch ON sch.SubCNo = vers.SubCNo
    LEFT OUTER JOIN commonschema.VC_REGVEREINB regv ON sch.SCH# = regv.SCH# AND SUBSTR(UPPER(sch.BUCHTEXT),1,2) = regv.SndReturnNo AND sch.SubCNo IS NULL
    LEFT OUTER JOIN myschema.T_CLAIMS_VT sch_vt ON sch.SCH# = sch_vt.SCH#

    Hi,
    metalray wrote:
    Hello Guys,
    I have a bit of trouble understanding the MERGE I have written here.
    All the code executes without errors. As far as I see,
    the below MERGE SELECT is a Cartesian product/cross join and I remember that is not
    good.Cross joins are good for some purposes. In practice, they're useful in only 1 or 2 queries out of every 1000.
    Using the old join notation, it was very easy to get a cross join by mistake. Given how rarely cross joins are needed, the vast majority of cross joins (using old notation) were not good, but that was the fault of the programmers and the notation, not an indication that cross join itself was bad.
    The ON (join condition) seems to be only for the merge into table (T_CLAIMS_BB) and
    the table that comes from the select (d).Exactly!
    You can have separate ON conditions inside the USING sub-query, if you need them.
    >
    merge into T_CLAIMS_BB t
    using
    SELECT sch_vt.SCH#,vert.CNO,vers.SubCNo,regv.ReturnNo,regv.SndReturnNo,sch_vt.MainProd,sch_vt.Prod
    FROM mainschema.TCONTRACT vert, mainschema.TVERSCONTRACT vers, commonschema.VC_REGVEREINB regv, myschema.T_CLAIMS_VT sch_vt
    ) d
    ON (
    t.sch# = d.sch# AND
    SUBSTR(UPPER(t.BOOKINGTEXT),1,2) = d.SndReturnNo AND d.SubCNo IS NULL
    ) -- Join
    when matched then
    update
    set t.CNO = 'a',
    t.ReturnNo = 'a',
    t.MainProd = 'b',
    t.Prod = 'c';
    I wonder now, what is the advantage of using MERGE in my case - if there is one.I don't see any advantage, but I suspect the statement, as written, is not doing what it's supposed to. If someone made the mistake of using MERGE when UPDATE would be better, that might be the least of the mistakes in this statement.
    Finally I want to demonstrate how the whole thing would look without a MERGE:It looks like the MERGE statement above is equivalent to:
    UPDATE     t_claims_bb
    SET     cno          = 'a'
    ,     returnno     = 'a'
    ,     mainprod     = 'b'
    ,     prod          = 'c'
    WHERE     UPPER (SUBSTR (bookingtext, 1, 2)) IN
              SELECT  returnno
              FROM     commonschema.vc_regvereinb
    AND     EXISTS
              SELECT  1
              FROM     mainschema.tverscontract
              WHERE     subcno     IS NULL
    AND     EXISTS
              SELECT     1
              FROM     mainschema.tcontract
    AND     EXISTS
              SELECT     1
              FROM     myschema.t_claims_vt
    ;Again, I suspect that the MERGE state,ment above is not doing what it was meant to do, or may coinncidentally be getting the right results on a small sample set. Many of the tables named in the USING clause of the MERGE statement do'nt seem to have much of a role in this problem.
    SELECT vers.* FROM TVERSCONTRACT vers
    LEFT OUTER JOIN myschema.T_CLAIMS_BB sch ON sch.SubCNo = vers.SubCNo
    LEFT OUTER JOIN commonschema.VC_REGVEREINB regv ON sch.SCH# = regv.SCH# AND SUBSTR(UPPER(sch.BUCHTEXT),1,2) = regv.SndReturnNo AND sch.SubCNo IS NULL
    LEFT OUTER JOIN myschema.T_CLAIMS_VT sch_vt ON sch.SCH# = sch_vt.SCH#What is this query? Perhaps you meant to have something like this in the USING clause of the MERGE.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    The sample data should show what the tables are like before the MERGE (or UPDATE), and the results will be the contents of the changed table after the MERGE.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using.

  • PI 7.1 runtime error: 2 messages are merged into one

    Hi,
    We have recently upgraded to 71. We are having a crtical issue with one of the interface. below are the details:
    Background:Interface is using ABAP mapping to convert an Idoc into file.
    File name is fed into u2018dynamic configurationu2019 in mapping program.
    File adapter uses dynamic file name and saves the file using NFS.
    Interface receives idocs in batch, so several Idocs are received by XI almost at the same time.
    Interface has been working without any problem in version 3.00 for last 3 years.
    Problem in 71.:On occasions (random, not always), 2 idocs are merged into one file. It means, only one file is created, which includes the data from 2 idocs.
    In message pipeline, same file name is shown both message (in dynamic config after mapping)
    We have tried u2018use temporary filenameu2019 option on file adapter, but problem is not resolved.
    Any sugegstion pelase!

    Hi,
    In your Graphical mapping create an UDF with code Thread.sleep(1000)  and map this udf to any node (may be root node).
    Note: The delay is in mili sec.
    This udf will delay the mapping for specific time. I am not sure if it is going to solve your problem but you can try.
    Regards,
    Sarvesh

  • Oracle 11g merge statement not working properly

    HI I have recently my oracle version to 11.2.0.3 -64 bit . My merge statement is geeting failied saying that invlid identfier at line number 18    
    MERGE INTO peer_index indx        USING staging.stg_peer_filing stg          ON (indx.peer_element_code = stg.fund_code                and indx.index_effective_date = trunc(stg.pricing_date))        WHEN MATCHED THEN UPDATE          SET indx.filing_date = trunc(stg.filing_date),            indx.reported_net_assets = stg.net_assets,            indx.active_flag = 'N',            indx.parent_index_code = NULL,            indx.update_datetime = systimestamp,            indx.last_update_user_id = user        WHEN NOT MATCHED THEN INSERT         (index_code, peer_element_code, filing_date, index_effective_date,          reported_net_assets, active_flag          )        VALUES         ((SELECT pe.index_code_prefix || to_char(stg.pricing_date,'MMRR')           FROM fi_benchmark.peer_element pe           WHERE pe.peer_element_code = stg.fund_code),          stg.fund_code, trunc(stg.filing_date), trunc(stg.pricing_date),          stg.net_assets, 'N'         );
    please help why this is happening .Same query works fine in 10g .

    which line is the line that has the error?
    merge INTO peer_index indx
    USING staging.stg_peer_filing stg
    ON (indx.peer_element_code = stg.fund_code AND indx.index_effective_date = Trunc
    (stg.pricing_date))
    WHEN matched THEN
      UPDATE SET indx.filing_date = Trunc(stg.filing_date),
                 indx.reported_net_assets = stg.net_assets,
                 indx.active_flag = 'N',
                 indx.parent_index_code = NULL,
                 indx.update_datetime = systimestamp,
                 indx.last_update_user_id = USER
    WHEN NOT matched THEN
      INSERT (index_code,
              peer_element_code,
              filing_date,
              index_effective_date,
              reported_net_assets,
              active_flag )
      VALUES ((SELECT pe.index_code_prefix
                      || To_char(stg.pricing_date, 'MMRR')
               FROM   fi_benchmark.peer_element pe
               WHERE  pe.peer_element_code = stg.fund_code),
              stg.fund_code,
              Trunc(stg.filing_date),
              Trunc(stg.pricing_date),
              stg.net_assets,
              'N' );

  • Merge Into works in SQL, fails in PL/SQL

    Database is 9i (Oracle9i Enterprise Edition Release 9.2.0.5.0)<br>
    <br>
    The 9i documentation--PL/SQL User's Guide and Reference
    Release 2 (9.2)--makes it seem like this is part of the PL/SQL language, but the compiler disagrees.<br>
    <br>
    Anyone else encounter this?<br>
    <br>
    Test case:<br>
    create table kev(d date, n number);<br><br>
    Table created.<br>
    <br>
    ..it works in SQL...<br>
    MERGE INTO kev k<br>2 USING ( SELECT 1 n, sysdate d from dual ) s<br>
    3 ON ( k.n = s.n )<br>
    4 WHEN MATCHED THEN<br>
    5 UPDATE<br>
    6 SET k.d = s.d<br>
    7 WHEN NOT MATCHED THEN<br>
    8 INSERT (n,d)<br>
    9 VALUES (s.n, s.d);<br>
    <br>
    1 row merged.<br>
    <br>
    ..but not in PL/SQL...<br>
    begin<br>2 MERGE INTO kev k<br>
    3 USING ( SELECT 1 n, sysdate d from dual ) s<br>
    4 ON ( k.n = s.n )<br>
    5 WHEN MATCHED THEN<br>
    6 UPDATE<br>
    7 SET k.d = s.d<br>
    8 WHEN NOT MATCHED THEN<br>
    9 INSERT (n,d)<br>
    10 VALUES (s.n, s.d);<br>
    11 end;<br>
    12 /<br>
    MERGE INTO kev k<br>
    *<br>
    ERROR at line 2:<br>
    ORA-06550: line 2, column 7:<br>
    PLS-00103: Encountered the symbol "INTO" when expecting one of the following:
    := . ( @ % ; <a SQL statement><br>
    <br>
    Thanks.

    Answer
    There are indeed DB parameters conflicting with the MERGE statement. The DB I am working on is for Oracle Applications. Apparently, although the applications are certified to run on current databases, the underlying code base has not really been brought up, and users are forced into some backward compatibility constraints. So I am stuck until we get our application upgraded from 11.5.7 to something better.
    Hope this helps someone else.
    Kevin
    From the database initialization parameters:
    # Events
    # Events should not be set unless directed by Oracle Support,
    # or by instruction as per the Applications documentation.
    # The following events should be set for PL/SQL backward
    # compatibility.
    # These events should only be used if you are using Oracle
    # Applications release 11.5.7. For later releases (i.e. 11.5.8
    # or higher), you should remove these events.
    event="10932 trace name context level 32768"
    event="10933 trace name context level 512"
    event="10943 trace name context level 16384"

  • MERGE INTO

    Hi All,
    i need an expert advice in this matter, and if possible please explain with some code/example.Here is the situation.
    This process will read all records in the STAGING_TABLE and process the data into the MY_DATABASE tables.
    STG_ID will be used to populate the MY_ID with in MY_DATABASE.
    Any records that fail the load process will be flagged as 'error' by populating the ERROR_TABLE with the reson for the failure. After the load has been performed, all error records will be corrcted and reloaded.
    outline as below:
    1. Read all staging table records.
    2. Use the STG_ID value to determine whether the record already exists with in the MY_DATABASE tables.
    3. If not exist, create the one with associated records.
    4. If exists, compare the staging data to the MY_DATABASE data as per the rules. Then update the appropriate data in MY_DATABASE.
    5. If any records are invalid, update the staging table record with the error message.
    6. create a record in MY_LOGS table to indicate successfull completion of the process as well as the number of records processed.
    Now my approach is to use MERGE INTO path. I know that we can do it with the help of PL/SQL. given the above scenerio which approach is the better one. we have millions of records to be processed. Do merge has the capability to take care of all the logics i.e(insert/update/logs/bad-records)
    can we use Merge in procedure and packages ?
    please give me some advise in this matter .
    Thanks!

    read the following , you might get a better idea
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_915a.htm#SQLRF01606
    Have you considered using External Tables ?

  • JLabel Text merges into JComboBox - GBLayout bug?

    Hello,
    http://666kb.com/i/ayv9fbt03b8v1bkcy.png
    as you can see the text of the JLabel goes into the JComboBox, buy why? The Code looks ok to me:
    panel3.setLayout(new GridBagLayout());       
           addJComponentToJPanel( panel3,movieFormatLB       ,0 , 0 , 4 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
           addJComponentToJPanel( panel3,movieFormatCB       ,1 , 0 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);      
           addJComponentToJPanel( panel3,movieFormatAddBT    ,2 , 0 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
           addJComponentToJPanel( panel3,movieFormatDelBT    ,3 , 0 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
           addJComponentToJPanel( panel3,playLengthLB        ,0 , 1 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
           addJComponentToJPanel( panel3,playLengthCB        ,1 , 1 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);      
           addJComponentToJPanel( panel3,playLengthAddBT     ,2 , 1 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
           addJComponentToJPanel( panel3,playLengthDelBT     ,3 , 1 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
           addJPanelToJFrame( panel3,0,2,1,1,1,5,GridBagConstraints.NORTH,GridBagConstraints.BOTH);        another problem is why can`t I change the width of the add/del Buttons? I can enter any value in in weightX doesnt matter nothing changes?

    void addJComponentToJPanel(JPanel panel, JComponent c, int gridx, int gridy, int gridwidth, int gridheight, double weightx, double weighty, int anchor, int fill )
             panel.add(c, new GridBagConstraints(gridx, gridy, gridwidth, gridheight, weightx, weighty, anchor, fill, new Insets(0, 0, 0, 0), 0, 0));       
        }when i change this line:
    addJComponentToJPanel( panel3,movieFormatCB       ,1 , 0 , 1 , 1 , 1 , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH); to this:
    addJComponentToJPanel( panel3,movieFormatCB ,1 , 0 , 1 , 1 , *30* , 1 , GridBagConstraints.NORTH,GridBagConstraints.BOTH);
    JLabel + JComboBox are still more merging into each other not only that the add/del Buttons dont get smaller by widening the JComboBox but this is what i wanna achieve.

  • MERGE INTO error

    Hi,
    I'm trying to use the MERGE INTO statement. I wrote a script with all the statements. Everything runs fine EXCEPT for one statement:
    MERGE INTO TEMPLATE_COMPONENT_TMP2 A USING
    (SELECT
      1011 as "TEMPLATE_COMPONENT_ID",
      'Service Canada Logo' as "TEMPLATE_COMPONENT_NAME_EN",
      'Logo de Service Canada' as "TEMPLATE_COMPONENT_NAME_FR",
      TO_DATE('06/03/2009 15:25:08', 'MM/DD/YYYY HH24:MI:SS') as "PRODUCTION_START_DATE",
      TO_DATE('06/03/2009 15:25:08', 'MM/DD/YYYY HH24:MI:SS') as "DATE_CREATED",
      1 as "USER_CREATED",
      1 as "CD_TMPLT_COMPONENT_CTGRY_ID",
      'Service Canada Logo' as "TEMPLATE_COMPONENT_DESC_EN",
      'Logo de Service Canada' as "TEMPLATE_COMPONENT_DESC_FR",
      NULL as "PRODUCTION_END_DATE",
      TO_DATE('06/03/2009 15:31:28', 'MM/DD/YYYY HH24:MI:SS') as "DATE_UPDATED",
      NULL as "USER_UPDATED",
      2 as "CD_LANGUAGE_ID",
      1 as "EDITABLE_IND",
      1 as "VERSION_NUMBER",
      3 as "CD_TMPLT_COMPONENT_TP_ID",
      1 as "CD_EXTERNAL_DATA_SOURCE_ID",
      1 as "SHARED_IND",
      NULL as "CD_FIELD_FORMAT_TYPE_ID",
      NULL as "FIELD_FORMAT_ALGORITHM",
      NULL as "DATASOURCE_TAG",
      NULL as "MAPPING_COLUMN_NAME",
      NULL as "MAPPING_TABLE_NAME",
      1 as "MANDATORY_COMPONENT_IND",
      'Change-over: CLS to ACS' as "REASON_TEXT",
      NULL as "CHANGE_DESCRIPTION",
      '<ns0:para component_code="1011" xmlns:ns0="http://acs.prv/templateComponents"><w:p xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml"><w:pPr><w:pStyle w:val="Header" /></w:pPr><w:r><w:pict><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml"><v:stroke joinstyle="miter" /><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0" /><v:f eqn="sum @0 1 0" /><v:f eqn="sum 0 0 @1" /><v:f eqn="prod @2 1 2" /><v:f eqn="prod @3 21600 pixelWidth" /><v:f eqn="prod @3 21600 pixelHeight" /><v:f eqn="sum @0 0 1" /><v:f eqn="prod @6 1 2" /><v:f eqn="prod @7 21600 pixelWidth" /><v:f eqn="sum @8 21600 0" /><v:f eqn="prod @7 21600 pixelHeight" /><v:f eqn="sum @10 21600 0" /></v:formulas><v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect" /><o:lock v:ext="edit" aspectratio="t" /></v:shapetype><w:binData w:name="wordml://02000001.jpg">/9j/4AAQSkZJRgABAgEBLAEsAAD/4Qo0RXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUA
    AAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAExAAIAAAAdAAAAcgEyAAIAAAAUAAAAj4dp
    AAQAAAABAAAApAAAANAAAAEsAAAAAQAAASwAAAABQWRvYmUgUGhvdG9zaG9wIENTIE1hY2ludG9z
    aAAyMDA1OjA5OjE1IDE1OjQ4OjUxAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAlqADAAQAAAAB
    AAAAHwAAAAAAAAAGAQMAAwAAAAEABgAAARoABQAAAAEAAAEeARsABQAAAAEAAAEmASgAAwAAAAEA
    AgAAAgEABAAAAAEAAAEuAgIABAAAAAEAAAj+AAAAAAAAAEgAAAABAAAASAAAAAH/2P/gABBKRklG
    AAECAQBIAEgAAP/tAAxBZG9iZV9DTQAB/+4ADkFkb2JlAGSAAAAAAf/bAIQADAgICAkIDAkJDBEL
    CgsRFQ8MDA8VGBMTFRMTGBEMDAwMDAwRDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAENCwsN
    Dg0QDg4QFA4ODhQUDg4ODhQRDAwMDAwREQwMDAwMDBEMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM
    DAwM/8AAEQgAHwCWAwEiAAIRAQMRAf/dAAQACv/EAT8AAAEFAQEBAQEBAAAAAAAAAAMAAQIEBQYH
    CAkKCwEAAQUBAQEBAQEAAAAAAAAAAQACAwQFBgcICQoLEAABBAEDAgQCBQcGCAUDDDMBAAIRAwQh
    EjEFQVFhEyJxgTIGFJGhsUIjJBVSwWIzNHKC0UMHJZJT8OHxY3M1FqKygyZEk1RkRcKjdDYX0lXi
    ZfKzhMPTdePzRieUpIW0lcTU5PSltcXV5fVWZnaGlqa2xtbm9jdHV2d3h5ent8fX5/cRAAICAQIE
    BAMEBQYHBwYFNQEAAhEDITESBEFRYXEiEwUygZEUobFCI8FS0fAzJGLhcoKSQ1MVY3M08SUGFqKy
    gwcmNcLSRJNUoxdkRVU2dGXi8rOEw9N14/NGlKSFtJXE1OT0pbXF1eX1VmZ2hpamtsbW5vYnN0dX
    Z3eHl6e3x//aAAwDAQACEQMRAD8ArK30j/lXD/4+v/qgqit9I/5Vw/8Aj6/+qCz47jze0y/zc/7s
    vyfU1kdd6/j9MptrmMz0w6hhBhxcSwOn6P6N300H60dZy+ksosxjWfVLmOreJPEtsZDm/RXG9R6t
    ' as "TEMPLATE_COMPONENT_CONTENT",
      1011 as "TEMPLATE_COMPONENT_CODE",
      0 as "FREQUENCY_IND",
      0 as "REPEAT_IND",
      'ACS' as "REQUESTED_BY",
      'ACS' as "APPROVED_BY",
      NULL as "CD_PROGRAM_GROUP_ID_BAK"
      FROM DUAL) B
    ON (A.TEMPLATE_COMPONENT_ID = B.TEMPLATE_COMPONENT_ID)
    WHEN NOT MATCHED THEN
    INSERT (
      TEMPLATE_COMPONENT_ID, TEMPLATE_COMPONENT_NAME_EN, TEMPLATE_COMPONENT_NAME_FR, PRODUCTION_START_DATE, DATE_CREATED,
      USER_CREATED, CD_TMPLT_COMPONENT_CTGRY_ID, TEMPLATE_COMPONENT_DESC_EN, TEMPLATE_COMPONENT_DESC_FR, PRODUCTION_END_DATE,
      DATE_UPDATED, USER_UPDATED, CD_LANGUAGE_ID, EDITABLE_IND, VERSION_NUMBER,
      CD_TMPLT_COMPONENT_TP_ID, CD_EXTERNAL_DATA_SOURCE_ID, SHARED_IND, CD_FIELD_FORMAT_TYPE_ID, FIELD_FORMAT_ALGORITHM,
      DATASOURCE_TAG, MAPPING_COLUMN_NAME, MAPPING_TABLE_NAME, MANDATORY_COMPONENT_IND, REASON_TEXT,
      CHANGE_DESCRIPTION, TEMPLATE_COMPONENT_CONTENT, TEMPLATE_COMPONENT_CODE, FREQUENCY_IND, REPEAT_IND,
      REQUESTED_BY, APPROVED_BY, CD_PROGRAM_GROUP_ID_BAK)
    VALUES (
      B.TEMPLATE_COMPONENT_ID, B.TEMPLATE_COMPONENT_NAME_EN, B.TEMPLATE_COMPONENT_NAME_FR, B.PRODUCTION_START_DATE, B.DATE_CREATED,
      B.USER_CREATED, B.CD_TMPLT_COMPONENT_CTGRY_ID, B.TEMPLATE_COMPONENT_DESC_EN, B.TEMPLATE_COMPONENT_DESC_FR, B.PRODUCTION_END_DATE,
      B.DATE_UPDATED, B.USER_UPDATED, B.CD_LANGUAGE_ID, B.EDITABLE_IND, B.VERSION_NUMBER,
      B.CD_TMPLT_COMPONENT_TP_ID, B.CD_EXTERNAL_DATA_SOURCE_ID, B.SHARED_IND, B.CD_FIELD_FORMAT_TYPE_ID, B.FIELD_FORMAT_ALGORITHM,
      B.DATASOURCE_TAG, B.MAPPING_COLUMN_NAME, B.MAPPING_TABLE_NAME, B.MANDATORY_COMPONENT_IND, B.REASON_TEXT,
      B.CHANGE_DESCRIPTION, B.TEMPLATE_COMPONENT_CONTENT, B.TEMPLATE_COMPONENT_CODE, B.FREQUENCY_IND, B.REPEAT_IND,
      B.REQUESTED_BY, B.APPROVED_BY, B.CD_PROGRAM_GROUP_ID_BAK)
    WHEN MATCHED THEN
    UPDATE SET
      A.TEMPLATE_COMPONENT_NAME_EN = B.TEMPLATE_COMPONENT_NAME_EN,
      A.TEMPLATE_COMPONENT_NAME_FR = B.TEMPLATE_COMPONENT_NAME_FR,
      A.PRODUCTION_START_DATE = B.PRODUCTION_START_DATE,
      A.DATE_CREATED = B.DATE_CREATED,
      A.USER_CREATED = B.USER_CREATED,
      A.CD_TMPLT_COMPONENT_CTGRY_ID = B.CD_TMPLT_COMPONENT_CTGRY_ID,
      A.TEMPLATE_COMPONENT_DESC_EN = B.TEMPLATE_COMPONENT_DESC_EN,
      A.TEMPLATE_COMPONENT_DESC_FR = B.TEMPLATE_COMPONENT_DESC_FR,
      A.PRODUCTION_END_DATE = B.PRODUCTION_END_DATE,
      A.DATE_UPDATED = B.DATE_UPDATED,
      A.USER_UPDATED = B.USER_UPDATED,
      A.CD_LANGUAGE_ID = B.CD_LANGUAGE_ID,
      A.EDITABLE_IND = B.EDITABLE_IND,
      A.VERSION_NUMBER = B.VERSION_NUMBER,
      A.CD_TMPLT_COMPONENT_TP_ID = B.CD_TMPLT_COMPONENT_TP_ID,
      A.CD_EXTERNAL_DATA_SOURCE_ID = B.CD_EXTERNAL_DATA_SOURCE_ID,
      A.SHARED_IND = B.SHARED_IND,
      A.CD_FIELD_FORMAT_TYPE_ID = B.CD_FIELD_FORMAT_TYPE_ID,
      A.FIELD_FORMAT_ALGORITHM = B.FIELD_FORMAT_ALGORITHM,
      A.DATASOURCE_TAG = B.DATASOURCE_TAG,
      A.MAPPING_COLUMN_NAME = B.MAPPING_COLUMN_NAME,
      A.MAPPING_TABLE_NAME = B.MAPPING_TABLE_NAME,
      A.MANDATORY_COMPONENT_IND = B.MANDATORY_COMPONENT_IND,
      A.REASON_TEXT = B.REASON_TEXT,
      A.CHANGE_DESCRIPTION = B.CHANGE_DESCRIPTION,
      A.TEMPLATE_COMPONENT_CONTENT = B.TEMPLATE_COMPONENT_CONTENT,
      A.TEMPLATE_COMPONENT_CODE = B.TEMPLATE_COMPONENT_CODE,
      A.FREQUENCY_IND = B.FREQUENCY_IND,
      A.REPEAT_IND = B.REPEAT_IND,
      A.REQUESTED_BY = B.REQUESTED_BY,
      A.APPROVED_BY = B.APPROVED_BY,
      A.CD_PROGRAM_GROUP_ID_BAK = B.CD_PROGRAM_GROUP_ID_BAK;
    [/code]
    It's giving me:
    '<ns0 ara component_code="1011" xmlns:ns0="http://acs.prv/templateComponents"><w  xmlns:w="http:
    ERROR at line 29:
    ORA-01704: string literal too long
    I guess it's NORMAL because a string max length is 4000 char. Here I have a CLOB.
    What can I do to workaround this problem?
    Thanks in advance,
    Marc.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Let me explain the FULL picture...
    We have 3 environments (databases) with the same table structure. I have to take the data from Table A, in DEV database, and copy it to Table A, in TST and PROD database. They don't want to loose any data that is already in TST and PROD. PLUS, I can't use any DATABASE LINKS (against OUR standards). This is why I was thinking of using the MERGE or UPDATE statements.
    I have a script that reads Table A, and builds a script with all the UPDATE statement. Then I found that TOAD could build a MERGE INTO script for me, so I did that. When I tried executing the MERGE script, I got the STRING error (max of 4000 char exeeded).
    What are my alternatives?
    Please advise !
    Thanks in advance,
    Marc.

  • Subquery inside Merge Into under 11g

    create or replace
    PROCEDURE SP_IN_CURRENCY
    IS
    CURSOR csr IS SELECT currency_code FROM in_currency ORDER BY currency_code;
    v_hkd_rate NUMBER(15,9);
    BEGIN
    SELECT spot_rate INTO v_hkd_rate FROM in_currency WHERE in_currency.currency_code = 'HKD';
    MERGE INTO currency USING
    (SELECT currency_code, spot_rate FROM in_currency WHERE in_currency.currency_code = 'HKD') rec_in_currency
    ON (currency.currency_code = rec_in_currency.currency_code)
    WHEN MATCHED THEN
    UPDATE
    SET currency.CURRENCY_NAME = NVL(
    (SELECT value
    FROM tb_resources
    WHERE PACKAGE = 'currency'
    AND locale = 'en_US'
    AND KEY = rec_in_currency.currency_code
    ), currency.CURRENCY_NAME),
    currency.spot_rate = (v_hkd_rate/rec_in_currency.spot_rate),
    currency.SPOT_RATE_IN_USD = rec_in_currency.spot_rate
    WHEN NOT MATCHED THEN
    INSERT
    currency_code,
    CURRENCY_NAME,
    spot_rate,
    SPOT_RATE_IN_USD
    VALUES
    rec_in_currency.currency_code,
    (SELECT value FROM tb_resources WHERE PACKAGE = 'currency' AND locale = 'en_US' AND KEY = rec_in_currency.currency_code),
    (v_hkd_rate/rec_in_currency.spot_rate),
    rec_in_currency.spot_rate
    COMMIT;
    END SP_IN_CURRENCY;
    The above stored procedure created successfully in 9i but retrun the following error when create on 11g. Anyone has idea? is it the limitation of 11g? The problem was caused by this subquery:
    (SELECT value FROM tb_resources WHERE PACKAGE = 'currency' AND locale = 'en_US' AND KEY = rec_in_currency.currency_code),
    Error(38,99): PL/SQL: ORA-00904: "REC_IN_CURRENCY"."CURRENCY_CODE": invalid identifier

        value assign in variable equals value return by subquery in USING clause
        so   (V_HKD_RATE / REC_IN_CURRENCY.SPOT_RATE) = 1
        and  CURRENCY_CODE = 'HKD'
        key = rec_in_currency.currency_code is always 'HKD'
        let's say
        SPOT_RATE  = 999
        v_hkd_rate = 999
    -- BEFORE:
    select  spot_rate
    into    v_hkd_rate
    from    in_currency
    where   in_currency.currency_code = 'HKD';
    merge into currency using
        select  currency_code, spot_rate
        from    in_currency
        where   in_currency.currency_code = 'HKD'
    ) rec_in_currency
    on
        currency.currency_code = rec_in_currency.currency_code
    when matched then update set
        currency.currency_name = nvl
                                        select  value
                                        from    tb_resources
                                        where   package = 'currency'
                                        and     locale = 'en_US'
                                        and     key = rec_in_currency.currency_code
                                ,   currency.currency_name
    ,currency.spot_rate           = (v_hkd_rate / rec_in_currency.spot_rate)
    ,currency.spot_rate_in_usd    = rec_in_currency.spot_rate
    when not matched then insert
        currency_code
    ,   currency_name
    ,   spot_rate
    ,   spot_rate_in_usd
    values
        rec_in_currency.currency_code
            select  value
            from    tb_resources
            where   package = 'currency'
            and     locale  = 'en_US'
            and     key     = rec_in_currency.currency_code
    ,    (v_hkd_rate/rec_in_currency.spot_rate)
    ,    rec_in_currency.spot_rate
    -- AFTER:
    merge into currency using
        select  currency_code, spot_rate
         -- 'HKD', 999
        from    in_currency
        where   in_currency.currency_code = 'HKD'
    ) rec_in_currency
    on
        currency.currency_code = 'HKD'
    when matched then update set
        /* If value IS NULL update with current value? I think you should change it... */
        currency.currency_name = nvl
                                        select  value
                                        from    tb_resources
                                        where   package = 'currency'
                                        and     locale  = 'en_US'
                                        and     key     ='HKD'
                                ,   currency.currency_name
    ,    currency.spot_rate        = 999/999
    ,    currency.spot_rate_in_usd = 999
    when not matched then insert
        currency_code
    ,   currency_name
    ,   spot_rate
    ,   spot_rate_in_usd
    values
        'HKD'
            select  value
            from    tb_resources
            where   package = 'currency'
            and     locale  = 'en_US'
            and     key     = 'HKD'
    ,   999/999
    ,   999
    Can anybody check it?
    */

  • Oracle physru rolling upgrade problem

    Hi, I'm having a problem with the Oracle Physru script provided from MOS note # 949322 I was hoping I could get some help with.
    My system contains of two Oracle 11.1.0.7.0, one primary and one physical standby.
    The hosts are two Oracle Solaris 10 Sparc x64 machines.
    My goal is to update from 11.1.0.7.0 to 11.1.0.7.8 using the script that is provided, however I'm bumping into problems at the step where the script is checking the Apply lag on the logical standby (function "get_apply_lag"). The lag seems to increase, and to be that indicates a problem with the redo apply process. However, when I query the DBA_LOGSTDBY_EVENTS View i get the following:
    SQL> SELECT EVENT_TIME, STATUS, EVENT FROM DBA_LOGSTDBY_EVENTS ORDER BY EVENT_TIMESTAMP, COMMIT_SCN;
    EVENT_TIME STATUS EVENT
    20-SEP-11 16:02:12 ORA-16111: log mining and apply setting up
    20-SEP-11 16:02:12 Apply LWM 848622, HWM 848622, SCN 848622
    Showing the output from Primary archive dest 2:
    SQL> show parameter log_archive_dest_2;
    NAME TYPE VALUE
    log_archive_dest_2 string service="test08db2", LGWR ASYNC NOAFFIRM delay=0 OPTIONAL compression=DISABLE max_failure=0 max_connections=1 reopen=300 db_unique_name="db_test08db2" net_timeout=30 valid_for=(online_logfile,primary_role)
    SQL>  select from v$LOGSTDBY_STATS;*
    NAME VALUE
    logminer session id 1
    number of preparers 1
    number of appliers 11
    server processes in use 15
    maximum SGA for LCR cache (MB) 50
    maximum events recorded 2000000000
    preserve commit order TRUE
    transaction consistency FULL
    record skipped errors Y
    record skipped DDLs Y
    record applied DDLs N
    NAME VALUE
    record unsupported operations Y
    realtime apply Y
    apply delay (minutes) 0
    coordinator state IDLE
    coordinator startup time 20-SEP-11 16:02:11
    coordinator uptime (seconds) 727
    txns received from logminer 62
    txns assigned to apply 29
    txns applied 29
    txns discarded during restart 33
    large txns waiting to be assigned 0
    NAME VALUE
    rolled back txns mined 4
    DDL txns mined 2
    CTAS txns mined 0
    bytes of redo mined 8195884
    bytes paged out 0
    pageout time (seconds) 0
    bytes checkpointed 709802
    checkpoint time (seconds) 0
    system idle time (seconds) 479
    standby redo logs mined 0
    archived logs mined 4
    NAME VALUE
    gap fetched logs mined 2
    standby redo log reuse detected 0
    logfile open failures 0
    current logfile wait (seconds) 0
    total logfile wait (seconds) 0
    thread enable mined 0
    thread disable mined 0
    distinct txns in queue 0
    41 rows selected.
    SQL> select type, high_scn, status, pid from v$logstdby order by type;
    TYPE HIGH_SCN STATUS PID
    ANALYZER 850320 ORA-16116: no work available 20702
    APPLIER 848808 ORA-16116: no work available 20719
    APPLIER 850320 ORA-16116: no work available 20731
    APPLIER 850204 ORA-16116: no work available 20727
    APPLIER 848895 ORA-16116: no work available 20725
    APPLIER 848665 ORA-16116: no work available 20705
    APPLIER 848677 ORA-16116: no work available 20709
    APPLIER 848728 ORA-16116: no work available 20713
    APPLIER 848740 ORA-16116: no work available 20715
    APPLIER 848796 ORA-16116: no work available 20717
    APPLIER 848842 ORA-16116: no work available 20721
    TYPE HIGH_SCN STATUS PID
    APPLIER 848854 ORA-16116: no work available 20723
    BUILDER 850320 ORA-16116: no work available 20221
    COORDINATOR 850326 ORA-16116: no work available 20119
    PREPARER 850318 ORA-16116: no work available 20223
    READER 850326 ORA-16116: no work available 20217
    16 rows selected.
    Physru Script Output:_
    ### Initialize script to either start over or resume execution
    Sep 20 14:35:41 2011 [0-1] Identifying rdbms software version
    Sep 20 14:35:41 2011 [0-1] database nobilldb is at version 11.1.0.7.0
    Sep 20 14:35:42 2011 [0-1] database nobilldb is at version 11.1.0.7.0
    Sep 20 14:35:44 2011 [0-1] verifying flashback database is enabled at db_test08db1 and db_test08db2
    Sep 20 14:35:44 2011 [0-1] verifying available flashback restore points
    Sep 20 14:35:45 2011 [0-1] verifying DG Broker is disabled
    Sep 20 14:35:46 2011 [0-1] looking up prior execution history
    Sep 20 14:35:46 2011 [0-1] purging script execution state from database db_test08db1
    Sep 20 14:35:46 2011 [0-1] purging script execution state from database db_test08db2
    Sep 20 14:35:47 2011 [0-1] starting new execution of script
    ### Stage 1: Backup user environment in case rolling upgrade is aborted
    Sep 20 14:35:47 2011 [1-1] stopping media recovery on db_test08db2
    Sep 20 14:35:48 2011 [1-1] creating restore point PRUP_0000_0001 on database db_test08db2
    Sep 20 14:35:49 2011 [1-1] backing up current control file on db_test08db2
    Sep 20 14:35:50 2011 [1-1] created backup control file /opt/oracle/product/11.1.0.7/dbs/PRUP_0001_db_test08db2_f.f
    Sep 20 14:35:50 2011 [1-1] creating restore point PRUP_0000_0001 on database db_test08db1
    Sep 20 14:35:51 2011 [1-1] backing up current control file on db_test08db1
    Sep 20 14:35:52 2011 [1-1] created backup control file /opt/oracle/product/11.1.0.7/dbs/PRUP_0001_db_test08db1_f.f
    NOTE: Restore point PRUP_0000_0001 and backup control file PRUP_0001_db_test08db2_f.f
    can be used to restore db_test08db2 back to its original state as a
    physical standby, in case the rolling upgrade operation needs to be aborted
    prior to the first switchover done in Stage 4.
    ### Stage 2: Create transient logical standby from existing physical standby
    Sep 20 14:35:53 2011 [2-1] verifying RAC is disabled at db_test08db2
    Sep 20 14:35:53 2011 [2-1] verifying database roles
    Sep 20 14:35:54 2011 [2-1] verifying physical standby is mounted
    Sep 20 14:35:54 2011 [2-1] verifying database protection mode
    Sep 20 14:35:55 2011 [2-1] verifying transient logical standby datatype support
    Sep 20 14:36:00 2011 [2-2] starting media recovery on db_test08db2
    Sep 20 14:36:11 2011 [2-2] confirming media recovery is running
    Sep 20 14:36:12 2011 [2-2] waiting for v$dataguard_stats view to initialize
    Sep 20 14:36:13 2011 [2-2] waiting for apply lag on db_test08db2 to fall below 30 seconds
    Sep 20 14:36:13 2011 [2-2] apply lag is now less than 30 seconds
    Sep 20 14:36:14 2011 [2-2] stopping media recovery on db_test08db2
    Sep 20 14:36:15 2011 [2-2] executing dbms_logstdby.build on database db_test08db1
    Sep 20 14:36:27 2011 [2-2] converting physical standby into transient logical standby
    Sep 20 14:36:52 2011 [2-3] opening database db_test08db2
    Sep 20 14:37:28 2011 [2-4] configuring transient logical standby parameters for rolling upgrade
    Sep 20 14:37:29 2011 [2-4] starting logical standby on database db_test08db2
    Sep 20 14:37:37 2011 [2-4] waiting until logminer dictionary has fully loaded
    Sep 20 14:37:58 2011 [2-4] dictionary load 17% complete
    Sep 20 14:38:09 2011 [2-4] dictionary load 32% complete
    Sep 20 14:38:19 2011 [2-4] dictionary load 43% complete
    Sep 20 14:38:30 2011 [2-4] dictionary load 59% complete
    Sep 20 14:38:40 2011 [2-4] dictionary load 62% complete
    Sep 20 14:38:50 2011 [2-4] dictionary load 70% complete
    Sep 20 14:39:01 2011 [2-4] dictionary load 72% complete
    Sep 20 14:39:11 2011 [2-4] dictionary load 75% complete
    Sep 20 14:40:54 2011 [2-4] dictionary load is complete
    Sep 20 14:41:00 2011 [2-4] waiting for v$dataguard_stats view to initialize
    Sep 20 14:41:01 2011 [2-4] waiting for apply lag on db_test08db2 to fall below 30 seconds
    Sep 20 14:42:02 2011 [2-4] current apply lag: 316
    Sep 20 14:42:32 2011 [2-4] current apply lag: 316
    Sep 20 14:43:03 2011 [2-4] current apply lag: 376
    Sep 20 14:43:33 2011 [2-4] current apply lag: 376
    Sep 20 14:44:03 2011 [2-4] current apply lag: 437
    Sep 20 14:44:34 2011 [2-4] current apply lag: 437
    Sep 20 14:45:04 2011 [2-4] current apply lag: 497
    Sep 20 14:45:35 2011 [2-4] current apply lag: 497
    Sep 20 14:46:05 2011 [2-4] current apply lag: 558
    Sep 20 14:46:36 2011 [2-4] current apply lag: 558
    Sep 20 14:47:06 2011 [2-4] current apply lag: 618
    I would appreciate any help I could get, I'm stuck =/
    Regards,

    http://www.oracle.com/technetwork/database/features/availability/maa-wp-11g-upgrades-made-easy-131972.pdf

Maybe you are looking for

  • PDF output generated by XML Publisher is not printing in Dotmatrix Printer

    Hi All, We have designed a template for a particular concurrent program to print it's output format in PDF. The concurrent is running fine and it has produced the output in PDF format. But we are unable to take a printout of the output in our Dotmatr

  • Passing Values to and from a Javascript rule - Agentry

    Hi; I am working on determining the first day and last day of the week using a javascript rule, so this can be in turn passed to an Agentry date and time property. When I debug in the ATE, it seems my javascript rule is always returning zero. What co

  • SAP standard performance&healthy reference indexes values

    Dear Gurus, In EWA report there are many sys performance & healthy indexes (see the list below). We can evaluate the system's healthy status through them. But we have to know the SAP standard reference values first. My question is where I can find ou

  • ConnectionPool config on MacOS X using Oracle

    I'm running WebLogic 7.x on MacOS X 10.2.1 with Oracle 9.2.x. I'm trying to configure a ConnectionPool to use the type 2 driver that comes with Oracle. I've tried multiple variations of driver name (ie. oracle.jdbc.pool.OracleDataSource, oracle.jdbc.

  • HUGE stupid mistake iOS 6- no more street view in maps!

    Yes, we can get Google Maps on our iphone 5 by going to maps.google.com on Safari (it will allow you to install it from the web and is NOT in the app store) but there is no street view on it.  The only thing that had street view was Apples's map app