I want to pass one validation DML statement on the trigger. Condition is below DML statement
select distinct t1.cid from table1 t1, table t2 where t1.cid=t2.cid and t1.status<>'5'
table1.status is not 5, then trigger will block delete transaction.
CREATE TRIGGER LOAD_DROPID_DEL on WMWHSE2.table2 INSTEAD OF DELETE AS Begin declare @caseid VARCHAR(10) select @caseid = deleted.cid from deleted If exists(select * from table1 t1,table2 t2 where t1.cid=t2.cid AND t1.STATUS<>'5' AND t2.cid=@caseid) begin Rollback Transaction RAISERROR ('Deletions not allowed after loaded ', 16, 1) end end
Will the above trigger will give correct solution?