Your form should insert data in a temporary table with the same structure as the destination.
CREATE TABLE retention_temp AS SELECT * FROM retention WHERE 1=0;
Create a trigger after insert containing the following merge command :
MERGE INTO retention r
USING retention_temp t
ON (r.participant_id=t.partic
WHEN MATCHED THEN
UPDATE SET
r.opting_out=t.opting_out
WHEN NOT MATCHED THEN
INSERT
(participant_id, opting_out)
VALUES
(t.participant_id, t.opting_out);
Main Topics
Browse All Topics





by: angelIIIPosted on 2006-03-06 at 07:02:02ID: 16114811
http://www.psoug.org/refer ence/merge .html
MERGE
INTO RETENTION d
USING (
SELECT participant_id, COUNT (*) as counter
FROM RETENTION
WHERE participant_id = participant_id1;
) q
ON a.participant_id = q.participant_id
WHEN MATCHED THEN
UPDATE SET opting_out = '1'
WHERE participant_id = q.participant_id;
WHEN NOT MATCHED THEN
INSERT (participant_id, opting_out )
VALUES (q.participant_id, '1' );