Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: MERGE - INSERT/UPDATE

Re: MERGE - INSERT/UPDATE

From: poratips shah via DBMonster.com <forum_at_DBMonster.com>
Date: Sat, 07 May 2005 09:21:59 GMT
Message-ID: <0d5e51632c394f5e84f67120a53d417b@DBMonster.com>


Thanks for your response.
Looking to my MERGE sql, Any another method I can use or I have to write the individual MERGE for each attribute type? I have another attribute like Ecomm_flag, weight ...

MERGE.sql



BEGIN
         MERGE INTO SKU_ATTR T
            USING (select sku_id,'BuyEP', EMP_FLAG from SKU_ATTR_UPLOAD) S
                 ON    (S.SKU_ID = T.SKU_ID and T.ATTRIBUTE_NAME = 'BuyEP')
      WHEN MATCHED THEN
      UPDATE
         SET       T.ATTRIBUTE_VALUE    =  DECODE
(S.EMP_FLAG,'','NULL',S.EMP_FLAG)
     WHEN NOT MATCHED THEN
     INSERT 

( T.SKU_ID,T.ATTRIBUTE_NAME,T.ATTRIBUTE_VALUE)
VALUES
( CASE etl.merge_counter(etl.c_inserting) WHEN 0 THEN S.SKU_ID END,
'BuyEP',DECODE(S.EMP_FLAG,'','NULL',S.EMP_FLAG) );
     DBMS_OUTPUT.PUT_LINE(TO_CHAR(SQL%ROWCOUNT) || ' rows merged.');
     DBMS_OUTPUT.PUT_LINE(TO_CHAR(etl.get_merge_insert_count) || ' rows
inserted.');
     DBMS_OUTPUT.PUT_LINE(TO_CHAR(etl.get_merge_update_count( SQL%ROWCOUNT
)) || ' rows updated.');
     etl.reset_counters;

--commit;
  END;
/
-- 
Message posted via http://www.dbmonster.com
Received on Sat May 07 2005 - 04:21:59 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US