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: newbie question about inserting using cursors

Re: newbie question about inserting using cursors

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Thu, 7 Feb 2002 19:20:54 +0100
Message-ID: <u65i7sgt23os1b@corp.supernews.com>

"Nico Liever" <nicoliever_at_yahoo.com> wrote in message news:d04d655.0202070500.6e6e6d21_at_posting.google.com...
> Hi,
>
> I'm using the following code to select a few records from one
> table and then insert them into another using a cursor.
>
> declare
> cursor people2_cur is
> select *
> from PEOPLE
> where SAL>2000;
> people2_rec PEOPLE2%ROWTYPE;
> begin
> for rec1 in people2_cur
> loop
> insert into PEOPLE2 values(rec1.MNR, rec1.NAME, rec1.ADRES,
rec1.CITY,rec1.SAL);
> exit when people2_cur%NOTFOUND;
> end loop;
> end;
>
> Is it possible to use a more general value-description in the insert?
> Instead of using:
> insert into PEOPLE2 values(rec1.MNR, rec1.NAME, rec1.ADRES,
rec1.CITY,rec1.SAL);
> something like :
> insert into PEOPLE2 rec1;
> to insert the whole record rec1 ?
>
> Thanks in advance,
>
> Nico.

No there isn't
In this particular case
insert into people2
select ... from people
is also to be preferred as that doesn't fetch all records (ie everything is done in the database)

Hth

--
Sybrand Bakker
Senior Oracle DBA

to reply remove '-verwijderdit' from my e-mail address
Received on Thu Feb 07 2002 - 12:20:54 CST

Original text of this message

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