Creation of 2 records from one.

Analytics
N/A

Creation of 2 records from one.

Hi all,
I need to create two records out of one, conditionally.
The situation is, i have a single record which contains a date field. I need to create another one with same values for all the fields except this date field. I know how to populate/manipulate the date field but dont know how to create two out of one records.
Please help....
1 REPLY
Enthusiast

Re: Creation of 2 records from one.

I may have got the wrong end of the stick but this works!

Good luck.

/* CREATE TEMP TABLE */
create multiset volatile table RT_TEST
(
colA byteint not null
,colB date format 'yyyymmdd' not null
,colC byteint not null
) primary index (colA)
on commit preserve rows;

/* INSERT TEST DATA */
insert into RT_TEST ( 1, 1080528, 10 );
insert into RT_TEST ( 2, 1080529, 20 );
insert into RT_TEST ( 3, 1080530, 30 );

/* SHOW DATA */
sel * from rt_test;

/* - SQL ABOVE RETURNS -
colA colB colC
1 28/05/2008 10
2 29/05/2008 20
3 30/05/2008 30
*/

/* CONDITIONAL INSERT */
INSERT INTO RT_TEST
SELECT
colA
,1081231
,colC
FROM RT_TEST
WHERE colB = 1080529;

/* SHOW DATA */
sel * from RT_TEST;

/* - SQL ABOVE RETURNS -
colA colB colC
1 28/05/2008 10
2 29/05/2008 20
2 31/12/2008 20
3 30/05/2008 30
*/