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 statement? only want to update or insert merging field values if not nul

Re: Merge statement? only want to update or insert merging field values if not nul

From: <fitzjarrell_at_cox.net>
Date: 10 Jul 2005 13:16:17 -0700
Message-ID: <1121026577.822545.188020@g14g2000cwa.googlegroups.com>

NormaJean S via DBMonster.com wrote:
> Hi,
> I'm getting used to the merge statement. I really like it. I am using it in
> combination with external tables.
> But I am pretty new at this (or pretty rusty, depending on your point of view)
> ....
>
> I would like to know how i can add "update if not null" logic to my merge
> statement (i hope it is possible).
>
> For example,
> MERGE
> INTO tab1
> USING tab2 ON (lower(tab1.title) = lower(tab2.title) )
> WHEN MATCHED THEN
> UPDATE SET
> tab1.code = tab2.code
> WHEN NOT MATCHED THEN
> INSERT (id,code,title,description )
> VALUES (....[std stuff]..... );
>
>
> in the update clause, i only want to update tab1.code with tab2.code if tab2.
> code is not null. Can I do that, if so, what's the syntax?
>
> please advise....
> thanks,
> Norma Jean
>
>
> --
> Message posted via http://www.dbmonster.com

       MERGE
            INTO tab1
         USING tab2 ON (lower(tab1.title) = lower(tab2.title) )
   WHEN MATCHED THEN
        UPDATE SET
                 tab1.code        = nvl(tab2.code, tab1.code)
   WHEN NOT MATCHED THEN
        INSERT (id,code,title,description )
        VALUES (....[std stuff]..... );


David Fitzjarell Received on Sun Jul 10 2005 - 15:16:17 CDT

Original text of this message

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