I have a database DB with table T (id int, version timestamp) and application APP that works with this database and table. What I need to do:
T.T.curTimeStamp. T.version > curTimeStamp. Their version is set in UPDATE statement using SQL functions, for example, now(), current_timestamp() etc. I mean UPDATE T SET version=now();After reading a lot of information I think about such solution:
read committed isolation level.TcurTimeStamp.However, some RDMS, for example H2 and Posgtresql return same value of now() functions inside one transaction. And as I understand then if some update transaction started before my select transaction AND update transaction finished after select transaction then row.version will be < curTimeStamp.
I am not very good in SQL transactions and I have doubts about my solution. Is this solution correct? If not, please, show my mistakes and right direction.