Attempting to Override Values Set by SQLComputeCode
Class Audit.ModifiedTracker [ abstract ] {
/// Last time this record was saved
Property LastModifiedTime As %TimeStamp [ SqlComputeCode = {Set {*}=$zdt($zts,3)}, SqlComputed, SqlComputeOnChange = ("%%INSERT", "%%UPDATE") ];
/// User responsible for modifying record
Property LastModifiedUser As %String [ SqlComputeCode = {set {*} = ..GetModifiedUser()}, SqlComputed, SqlComputeOnChange = ("%%INSERT", "%%UPDATE") ];
Now, I would like to migrate some historical audit data stored somewhere else to this standard auditing class. However, I need to set these sqlComputed properties with their values from the other source... not the values that would be computed (i.e. always the current time, and the user running the migration code).
I would like to avoid direct global manipulation if possible... is there a good way to do what I'm looking to do?
Product version: Caché 2018.1
As your properties are NOT Calculated then there is a Storage Entry (check Storage section)
they are persisted and not just there on run-time
Note that it requires that you're the only writer on the system during that update.
Thank you, @Robert Cemper and @Eduard Lebedyuk!
I did not know about MANAGEDEXTENT, assuming there was no way to use the same storage in another class. Ed's warning is relevant though, I can't ensure that there wouldn't be other concurrent writes.
Here is my working solution.... Subclassing of the record class with Setters for the 2 properties seems to work. Simply overriding the 2 properties without [ SqlComputed ] did not change the computed behavior.
My migration routine can now create and save objects of the HistoricalRecord class