Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Copying rows
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?