Question
· Nov 6, 2018

Detection of last update timestamp of each class row (DSTIME ?)

Hi,

Most of my classes are mapped from Globals. I want to access Cache classes from a BI software through ODBC connection.

'Last update' information does not exist in most of the classes. My question is whether there is a 'last update' timestamp that is automatically generated for each line in classes I can extract to external systems?

Thanks

Discussion (9)0
Log in or sign up to continue

What is great about InterSystems objects is that you exactly know what's going on with your data. 

You can look into the generated code for classes with Cache Storage and see where and when class writes the data into ^OBJ.DSTIME when the class has 

Parameter DSTIME As STRING [ Constraint = ",AUTO,MANUAL", Flags = ENUM ] = "AUTO";

So, there is no magic here:  DSTIME=AUTO parameter introduces "sets" into ^OBJ.DSTIME global in the places where records are being updated or created.

It doesn't work for non-standard SQL storage because DSTIME Parameter simply doesn't know about insert/update/delete procedures anything.

In your case you can forget about DSTIME and place this sets in Global (or inserts into some Record.ChangeHistory class) in the places, where your data is being inserted/updated/deleted.

You implement DSTIME on a class by doing the following in your persistent class:

Parameter DSTIME As STRING [ Constraint = ",AUTO,MANUAL", Flags = ENUM ] = "AUTO";
 

You will need to implement batching as well so you only pick up changes to a class from the last time you queried against DSTIME. I believe there are a few posts in the community that further discuss implementing DSTIME. 

Best of luck. 

Hi Yaniv!

As @Chris Thompson mentioned you can use DSTIME for automatic records changes tracking which will be stored in a special global. But I doubt if it works for classes with non-standard storage schema just by adding DSTIME=auto;

How do you add/update records in your application? You need to introduce special calls in your "create/update" procedures to track changes. DSTIME=auto; does exactly same adding "tracking" logic in SQL and Object requests for class changes. Maybe you can use some calls with DSTIME=manual; mode.

@Alexander Koblov  do you know if it is possible to use DSTIME somehow in this case?

Another approach which may work in your case is to use AUDIT to track the changes users made to DB and then analyze this data, e.g. like here. But I never did it for non-standard storage schema.

I think I got a bit closer.

When adding the DSTIME (Auto) parameter to a class according to the below, I indeed get the actions recorded in ^OBJ.DSTIME class.

Parameter DSTIME As STRING [ Constraint = ",AUTO,MANUAL", Flags = ENUM ] = "AUTO";

However, there are two exceptions:

  • The timestamp is not recorded (Highlighted in Red)
  • This works only for classes with Cache storage type. Changes in classes with SQL storage type are not recorded.

@Evgeny Shvarov