0

I am trying to query a bulk delete with a trigger, however the application that I am using (Clarity) deals with a bulk delete one line at a time.

For example if a user deletes 3 rows at once, instead of firing the TRIGGER once, it will fire the TRIGGER 3 separate times.

Therefore when I query the DELETED table within my trigger it will only ever have one row in it.

Is there a way around this?

My aim is to have all the deleted rows available at the one time so that I can query them together.

TreasaNGC
  • 62
  • 1
  • 10
  • 3
    this means that you also fire 3 delete statements, not one. If you want your trigger to fire only once than make a delete statement that deletes all 3 in the same call – GuidoG Aug 11 '17 at 15:37
  • The problem I see you having here is, you do not know how many records are being deleted. So if you used a trigger to capture the records and write them into another table, you don't know how many will come through. SQL just sees a singular delete, it doesn't know of any context, unless that is in the data itself? – Keith Aug 11 '17 at 15:38
  • @GuidoG unfortunately I cannot do that, I am restricted because of how the front end application (clarity) deals with deletions. As I mentioned in my question, the application itself deletes rows one by one even when the front end user selects the option to delete multiple rows at the one time. The application will still fire the trigger 3 times... I have no control over that, I can only control what is done within the trigger itself. – TreasaNGC Aug 11 '17 at 17:10
  • then it is impossible for any trigger to know what deletes it should bundle. The trigger can only see the records inside the delete statement nothing else. You can do queries from the trigger but for prior deleted records that wont help you, they are gone forever already – GuidoG Aug 14 '17 at 06:39
  • Your best change is an "instead of" trigger. It will fire when you delete records but not delete anything, you have to delete the record yourself in this trigger. – GuidoG Aug 14 '17 at 06:41

0 Answers0