SQL Server: Accessing transactional data in nested triggers -
i have following setup in ms sql server
tablea
id uniqueidentified
status nvarchar ('unknown', 'inprogress', 'completed')
other columns...
tableb
id uniqueidentified
lastmodifieddate date
other columns...
tablea has update trigger changes lastmodifieddate on tableb every time there change in tablea
tableb has trigger puts message ssb queue every time lastmodifieddate changed.
question: how modify trigger tableb in such way fire when status of table completed.
the challenge during modification of status in tablea trigger caused in tableb doesn’t have access latest value of tablea (e.g. completed)
i not interested in: 1) adding column tableb modified triggera when status == complete 2) using global temp table.
is there clever way this? (e.g. read "updated" value of triggera while in nested triggerb)
due transactional nature of things update triggers. after update triggers indeed simplify whole scenario prone tablea , tableb out of sync. reasonable solution found far filter out trigger tableb when tablea status not "complete" , add 3rd trigger on tablea replicate tableb trigger when status changes completed. not elegant wish , duplicates code.
Comments
Post a Comment