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

Home -> Community -> Usenet -> c.d.o.misc -> Re: best way to conditionally insert a row

Re: best way to conditionally insert a row

From: DA Morgan <damorgan_at_psoug.org>
Date: Fri, 10 Aug 2007 08:33:52 -0700
Message-ID: <1186760031.900720@bubbleator.drizzle.com>


pascal.dulleck_at_veda.net wrote:
> I've had a similar problem two weeks ago. I wanted to copy all data
> from one file to another, but let the existing rows in the target file
> stay unchanged. To do this with one INSERT ... SELECT statement, I
> found the following solution. (I haven't tried it in Oracle yet, but
> it works fine in MS SQL Server)
>
> insert into target (key1, key2, data1) select key1, key2, data1 from
> source where not exists (
> select target.key1 from target where target.key1 = source.key1
> and target.key2 = source.key2)
>
> Greetings
> Pascal
>

What do files have to do with inserts?

Are you aware of the MERGE statement?
http://www.psoug.org/reference/merge.html

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org
Received on Fri Aug 10 2007 - 10:33:52 CDT

Original text of this message

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