SQL calculated property rollback

Primary tabs

SQL, Caché

Greetings all,

I have a quick SQL question.  I am working with a class, which has a calculated property, which in turned indexed.
The calculation for this property is created based on another property value via: 
SqlComputeOnChange = attributes  - so basically every time I add a property attribute to my class, my new property 
is calculated based on some SqlComputeCode which calls some class method.

That initial setup works as designed.

Question: If my code for whatever reason gets to a ROLLBACK, does the calculated property always rolls back,
and it's index always cleared?   I assume so, and looking for confirmation.

Thank you,


  • 0
  • 0
  • 130
  • 0
  • 1


ROLLBACK should revert any changes in data which was done in a transaction, with some exceptions like $increment on Global.

You can look at this example.

Class User.Test Extends %Persistent

Property Name As %String;

Property CalcName As %String [ Calculated, SqlComputeCode = { set {*} = {Name} }, SqlComputed, SqlComputeOnChange = Name ];

Index ByName On CalcName;

Storage Default
<Data name="TestDefaultData">
<Value name="1">
<Value name="2">


Let's create first object

USER>s o=##class(Test).%New()

USER>set o.Name="testname"

USER>w o.%Save()

check saved in globals

USER>zw ^User.TestD,^User.TestI
^User.TestI("ByName"," TESTNAME",1)=""

and now open transaction, and do some changes.



TL1:USER>set o=##class(Test).%OpenId(1)

TL1:USER>s o.Name="testname2"

TL1:USER>w o.%Save()
TL1:USER>zw ^User.TestD,^User.TestI
^User.TestI("ByName"," TESTNAME2",1)=""

So, changes there, let's do rollback, and check data again.


USER>zw ^User.TestD,^User.TestI
^User.TestI("ByName"," TESTNAME",1)=""