Re: Using cursors to insert records

From: Tom Best <Tom.Best_at_bentley.com>
Date: Thu, 18 Nov 1999 13:56:40 -0500
Message-ID: <38344BE8.3A259422_at_bentley.com>


Of course, you could always do:

INSERT INTO Tab1 SELECT * FROM Tab2

In PL/SQL, use the DBMS_SQL.EXECUTE call to do this.

KRM wrote:

> I'm not entirely sure what your message text is talking about, so I'm
> going to give answering your question a shot using the title to guide
> me. If I understand you correctly, you want to be able to insert a
> bunch of records, based on records in a cursor. The easiest way is to
> use a for loop. For instance, if you have defined a cursor named
> my_cursor, you could say......
>
> FOR MY_REC IN MY_CURSOR LOOP
> INSERT into MY_TABLE
> (row1,
> row2)
> VALUES
> (MY_REC.row1,
> MY_REC.row2);
> END LOOP;
>
> You don't have to define MY_REC anywhere, just use it. This will go
> thru each record in the cursor and insert it into the table.
>
> Good luck!
>
> In article <0f8c6c44.7d50eece_at_usw-ex0110-075.remarq.com>,
> bungle <igoingNOigSPAM_at_mother.co.uk.invalid> wrote:
> > I *cannot* believe that ORACLE won't accept the following :
> >
> > INSERT INTO TABLE_1 VALUES (v_table_1)
> >
> > where v_table_1 is TABLE_1%ROWTYPE....
> >
> > There *must* be a workaround (other than explicitly naming
> > every column I want to insert into).
> >
> > Can anyone help?
> >
> > * Sent from AltaVista http://www.altavista.com Where you can also
> find related Web Pages, Images, Audios, Videos, News, and Shopping.
> Smart is Beautiful
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
Received on Thu Nov 18 1999 - 19:56:40 CET

Original text of this message