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: SQL ?? - Insert from multiple tables

Re: SQL ?? - Insert from multiple tables

From: Chinna <jchinna_at_enron.com>
Date: 1997/10/14
Message-ID: <01bcd8db$4c9fa6a0$06f7fb9b@eoghou1325.eog.enron.com>#1/1

> insert into table1
> (fld1, fld2, fld3)
> select
> a.fld1,
> b.fld2,
> 'test value'
> from
> table2 a,
> table3 b
> where
> a.fldx = 'val1' and
> b.fldy(+) = 'val2'
>

try that. It should work

let me know if this helped.

Chinna

Maris Gabalins <mg_at_it.lv> wrote in article <343CD5CF.41EA5CD8_at_it.lv>...
> Probably you need to use outer join feature of Oracle SQL.
>
> Sincerely
> Maris Gabalins
> mg_at_it.lv
>
> Dina April wrote:
>
> > Hi -
> >
> > I am ahving a problem with the following SQL statement:
> >
> > insert into table1
> > (fld1, fld2, fld3)
> > select
> > a.fld1,
> > b.fld2,
> > 'test value'
> > from
> > table2 a,
> > table3 b
> > where
> > a.fldx = 'val1' and
> > b.fldy = 'val2'
> >
> > What happens:
> >
> > If there is no record in table3 (b) where fldy = 'val2',
> > the new record is not inserted into table1
> >
> > What I want to happen:
> >
> > If there is no record in table3 (b) where fldy = 'val2',
> > the new record is inserted into table1 and fld2 is set to NULL
> >
> > How can I modify my SQL statement to do this?
> >
> > Thanks.
> >
> > Dave
> > --
> > David S. April Syclo LLC
> > (847) 842-0320 101 Lions Dr. - Suite 118
> > april_at_syclo.com Barrington, IL 60010
> >
> > "Paradise is exactly like where you are right now, only much, much,
 better."
> > - Laurie Anderson
>
>
>
>
Received on Tue Oct 14 1997 - 00:00:00 CDT

Original text of this message

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