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: Need MERGE without UPDATE clause

Re: Need MERGE without UPDATE clause

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: Thu, 07 Jul 2005 22:23:08 +0800
Message-ID: <42CD3ACC.6060@yahoo.com>


"NormaJean S via DBMonster.com" wrote:
>
> I have a question regarding the MERGE statment.
> Can I do a merge with no update clause?
> For example, in the merge below, when a match is found, can I "do nothing"?
>
> If I don't have a match, I want the insert, but if i have a match, i don't
> want to update the existing record with incoming data because the incoming
> data is not complete.
>
> please help. it's been a long time, i'm rusty at this.
> thanks.
>
> =============================================
>
> MERGE INTO SALES_FACT D
> USING SALES_JUL01 S
> ON (D.TIME_ID = S.TIME_ID
> AND D.STORE_ID = S.STORE_ID
> AND D.REGION_ID = S.REGION_ID)
> WHEN MATCHED THEN
> UPDATE
> SET d_parts = d_parts + s_parts
> WHEN NOT MATCHED THEN
> INSERT (D.TIME_ID ,D.STORE_ID ,D.REGION_ID, D.PARTS ,D.SALES_AMT ,D.
> TAX_AMT ,D.DISCOUNT)
> VALUES ( S.TIME_ID ,S.STORE_ID ,S.REGION_ID,S.PARTS ,S.SALES_AMT ,S.
> TAX_AMT ,S.DISCOUNT);
>
> --
> Message posted via DBMonster.com
> http://www.dbmonster.com/Uwe/Forums.aspx/oracle/200507/1

10g, the clauses become optional

-- 
Connor McDonald
Co-author: "Mastering Oracle PL/SQL - Practical Solutions"
Co-author: "Oracle Insight - Tales of the OakTable"

web: http://www.oracledba.co.uk
web: http://www.oaktable.net
email: connor_mcdonald_at_yahoo.com


"Semper in excremento, sole profundum qui variat."

------------------------------------------------------------
Received on Thu Jul 07 2005 - 09:23:08 CDT

Original text of this message

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