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: Oracle SQL - Help on copying record to same table with different value for primary key

Re: Oracle SQL - Help on copying record to same table with different value for primary key

From: Daniel Morgan <damorgan_at_exesolutions.com>
Date: Tue, 16 Apr 2002 14:47:11 GMT
Message-ID: <3CBC3969.E6935038@exesolutions.com>


Use native dynamic SQL.

Also seriously consider creating your primary keys with names that match the table on which they are located, and using the USING INDEX with the tablespace specified verbiage so that the indexes can be easily identified and the indexes are not in the same tablespace as the tables.

Daniel Morgan

Dennis Valente wrote:

> Here is my table:
>
> CREATE TABLE tblPerson (
> ProjectYear varchar2(4),
> ProjectNumber varchar2(4),
> ModificationNumber varchar2(3),
> Description varchar2(4000),
> Primary Key (ProjectYear,ProjectNumber,ModificationNumber));
>
> I want to be able to copy a record with a certain primary key value
> and insert into the same table with a different primary key value.
>
> I.E. (2002,0001,001,'This is a short project.')
> (2002,0001,002,'This is a short project.')
>
> A simple INSERT statement will normally do, however, I will have many
> tables like this one with the same primary key fields but different
> additional columns. I will be looping through a list of tablenames
> that will be predefined. Only the primary key columns will be the
> same, all other columns will vary. Inotherwards, I can not hardcode
> the columns for the INSERT statement.
>
> Any help would be greatly appreciated.
Received on Tue Apr 16 2002 - 09:47:11 CDT

Original text of this message

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