I have a scenario where I have to insert a record in TableA
only if the RecordId
exists in TableB
.
I have written an Instead of Trigger on TableA
for Insert
, in which I am checking if the RecordId
exists in TableB
, and if it exists then I am allowing the Insert
in TableA
by explicitly inserting the record in TableA
in that trigger.
I want to know can I write an After Trigger on TableA
, in which I do the same check, and in case if RecordId
is not found in TableB
then I delete the inserted record from TableA
.
My question is If I fire delete query on TableA
for the same record which I am inserting will it work, and prevent the record from being inserted from the TableA
actually.
AFTER
trigger ever be needed?