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

Home -> Community -> Usenet -> c.d.o.server -> Copying rows

Copying rows

From: Morten Bråten <mobra_at_statoil.com>
Date: 1998/12/17
Message-ID: <3678CAC1.85823AF2@statoil.com>#1/1

I have a table with 15-20 columns. The first column is the primary key, which I use a sequence to generate.

I want to copy n number of rows from the table and append them to the same table. The copied rows must get a new sequence number, since the primary key definition doesn't allow duplicates.

I can probably use something like
INSERT INTO table (keyfield, field2, field3, field4,..., fieldn) VALUES (SELECT sequence.nextval, field2, field3, field4, ..., fieldn FROM table WHERE ...)

But the problem is that my table structure is subject to frequent changes, and I would have to update the copy query/procedure each time
I changed the table. I'm looking for a way to programmatically get the column names,
and make a generic (PL/SQL) procedure that copies all fields (except the primary key, which is filled in by the sequence) to a new row.

Can anybody help me with this?

Received on Thu Dec 17 1998 - 00:00:00 CST

Original text of this message

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