MyNextHome
2009-03-03T13:45:00Z
Hi,

we are using "compare LastModificationTime only" feature.
When a DB record gets updated from outside GeniusConnect (our ASP application), the record timesstamp is not updated, so GeniusConnect is ignoring the changes. Is there a way to make the DB column auto updating ?

Administrator
2009-03-03T13:50:00Z
Hello,

Yes, you can create a trigger like this:
CREATE TRIGGER KeepUpdated on MyTable FOR UPDATE, INSERT AS 
BEGIN

   if not update(MyLastModificationTime) [i]--NOT updated from client application[/i]   
BEGIN
   update MyTable
   set 
      MyLastModificationTime= CURRENT_TIMESTAMP
   from 
      MyTable inner join inserted i on (
        MyTable.MyPrimaryKey = i.MyPrimaryKey 
   END

END

You can change the "if not update(MyLastModificationTime)" to
if (select APP_NAME () <> 'GeniusConnect'):
this version will update the MyLastModificationTime for all other process, except updates from GeniusConnect sync.


If you are using replication, you can also add:
"not for replication" to avoid changes during the replication process.



This example is based on SQL Server, but the idea is the same for any DB with trigger support.