no additional conditions on the when not matched
and t1.status should be part of the join condition
check for example
http://forums.teradata.com/forum/general/conditional-merge-into
Der Beginn aller Wissenschaften ist das Erstaunen, dass die Dinge sind, wie sie sind.-Aristoteles
how about
merge into T2
using T1
on t1.a = t2.a
and t1.status in (1,3)
when matched then...
?
Der Beginn aller Wissenschaften ist das Erstaunen, dass die Dinge sind, wie sie sind.-Aristoteles
you can't delete with merge.
check the manuals
Der Beginn aller Wissenschaften ist das Erstaunen, dass die Dinge sind, wie sie sind.-Aristoteles
Consider defining a trigger. I believe triggers are frequently used to capture history for audit purposes.
Hi:
The MERGE statement is INTENDED TO insert new records or UPDATE existing ones (as per SQL 2003 standarsd), never to DELETE records.
I don't know much about DB2, but the Oracle implementation is an extension of the standard and it can only DELETE UPDATED rows based upon the updated values.
You could try a TD multistatement request:
DELETE FROM T1 WHERE...
;INSERT INTO T2 ...
HTH.
Cheers.
Carlos.
ON need to specify the join condition between T1 and T2
You need to check the manual for the merge syntax.
Why do you insist on the merge?
Did you consider
Begin Transaction;
Insert into T2
select *
from T1
where status in ('L1','L3')
;
Delete from T1
where status in ('L1','L3')
;
End Transaction;
Der Beginn aller Wissenschaften ist das Erstaunen, dass die Dinge sind, wie sie sind.-Aristoteles


Hi All,
I have two tables:T1,T2. If status in T1 is either 1 or 2 I want to insert that row in T2 and delete that row from T1. Can I do that using Merge Into or any other way to do that in one query.
Thanks,
Terankit