Concurrency checking with Last Change Time
- by Lijo
I have a following three tables
Email (emailNumber, Address)
Recipients (reportNumber, emailNumber, lastChangeTime)
Report (reportNumber, reportName)
I have a C# application that uses inline queries for data selection.
I have a select query that selects all reports and their Recipients. Recipients are selected as comma separacted string.
During updating, I need to check concurrency. Currently I am using MAX(lastChangeTime) for each reportNumber. This is selected as maxTime. Before update, it checks that the
lastChangeTime <= maxTime. --//It works fine
One of my co-developers asked why not use GETDATE() as “maxTime” rather than using a MAX operation. That is also working. Here what we are checking is the records are not updated after the record selection time.
Is there any pitfalls in using GETDATE() for this purpose?