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: HowTo: Select from insert-table WHILE inserting

Re: HowTo: Select from insert-table WHILE inserting

From: Neal Ho <hone_at_mail.nih.gov>
Date: Thu, 27 Sep 2001 15:09:32 -0400
Message-ID: <3BB3796C.D84FF3AF@mail.nih.gov>


try this. Take the greatest of the old one and new one.

insert into tablea (age,name,highestyet) select tp.age,tp.name,greatest(tt.maxage,tt2.maxage2) from tablepersons tp, (select max(age) maxage from tablea) tt,(select max(age) maxage2 from tablepersons) tt2;;

Neal

Andreas Koch wrote:

> Hi,
>
> what is the best way to get something like
>
> insert into tablea (age,name,highestyet)
> select age,name,(select max(age) from tablea) from tablepersons;
>
> or, for versions below 8i,
>
> insert into tablea (age,name,highestyet)
> select tp.age,tp.name,tt.maxage
> from tablepersons tp, (select max(age) maxage from tablea) tt;
>
> to work correctly.
>
> These two scripts work, but maxage returns the highest age in
> tablea BEFORE the insert - i need the highest age WHILE
> the insert.
>
> Any ideas?
> The solution has to work without redefining the tables and
> from an SQL script batch run.
>
> --
> Andreas
> Who doesn't live can never die
Received on Thu Sep 27 2001 - 14:09:32 CDT

Original text of this message

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