#1 2012-01-23 14:20:18

array81
Member
From: Italy
Registered: 2010-07-23
Posts: 411

Update TModTime

Sometimes I use SQL to update my database records (with Database.EngineExecute function). I know I have to manually update my TModTime value in this case.
But how?

I want update it with officail server time, so I need:
1) retrieve server time
2) convert it on integer value
3) update my database

Can you explane me how I can do 1) and 2).

Thanks

Offline

#2 2012-01-23 16:50:30

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,667
Website

Re: Update TModTime

As explained by the documentation, you can retrieve the Server official time from the TSQLRest.ServerTimeStamp property.
This method is in fact immediate: an offset is retrieved at startup, and is used to compute the server time on the fly.

You can safely use the Int64 value retrieved by the TSQLRest.ServerTimeStamp property to update directly the corresponding field in your SQL code.
This is in fact what the ORM core of mORMot does for a TModTime value - see TSQLRecord.ComputeFieldsBeforeWrite.

Offline

Board footer

Powered by FluxBB