duplicating a record in SPL
Posted in 1996
Say I have a table called tab1 with three columns in it, called col1,
col2, col3.
col1 is a serial column that does not allow dups,
col2 is int, and col3 is int
How can I duplicate a record so it gets teh next serial number for col1,
but simply duplicates the values for col2, and col3? The only column name
that I want to hardcode is the serial column.
For example:
record1 looks like:
col1 = 100
col2 = 2
col3 = 3
I want to duplicate record1 and create a new record that looks like:
col1 = 101
col2 = 2
col3 = 3
insert into tab1 values (select * from tab1 where col1 = 100);will not work because I would duplicate the serial number.
select * from tab1 where col1 = 100 into temp temp_tab1;
alter table tab1 modify (col1 integer);
update temp_tab1 set col1 = 0 where col1 = 100;
insert into tab1 values (select * from temp_tab1);will not work because you cannot do an alter table on a temp table.
Any suggestions?
-Toby Denbow
== Toby Denbow ========================= tdenbow@mathworks.com ==
The MathWorks, Inc. info@mathworks.com
24 Prime Park Way http://www.mathworks.com
Natick, MA 01760-1500 ftp.mathworks.com
==== Tel: 508-653-1415 === Fax: 508-650-6725 ====================