Re: duplicating a record in SPL
Posted in 1996
Toby Denbow (tdenbow@mathworks.com) wrote:
: 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
How about this:
define t_col2 like tab1.col2;
define t_col3 like tab1.col3;
select col2, col3
into t_col2, t_col3
from tab1
where col1 = 100
insert into tab1 values (0, t_col2, t_col3)
Hope this helps.
Stefanie
--
Stefanie Vario
svario@zenacomp.com
ZenaComp Incorporated
http://www.zenacomp.com/~zenacomp