更新此列时更新其他列的值



我有问题,如何在系统间缓存中做类似触发器的事情。 情况: 例如,我有带有属性(列(的表 X 值 A,值 B 我想在值 A 被更新更改时更新值 B。我已经定义了全局变量 ^VALUEBGENER 并用于$SEQ函数递增它, 我的想法是:

Class User.X Extends %Persistent [ ClassType = persistent, DdlAllowed, Final, Owner = {_SYSTEM}, ProcedureBlock, SqlRowIdPrivate, SqlTableName = X]
{
Property VALUEA As %Library.String(MAXLEN = 8) [ Required,SqlColumnumber = 1];
Property VALUEB As %Library.Integer(MAXVAL = 2147483647, MINVAL = -2147483648) [ Required,SqlColumnNumber = 1,SqlComputed,SqlColumnumber = 2, SqlComputeCode = {SET {valueB}=$SEQ(^VALUEBGENER)}, SqlComputeOnChange = %%UPDATE];
}

但是当我更改 valuea 时它不起作用,但当我更改值时它有效 b 所以,知道吗? 附言对不起英语不好

可以通过添加触发器和 SqlCompute 来实现


Class User.X Extends %Persistent [ ClassType = persistent, DdlAllowed, Final, Owner = {_SYSTEM}, ProcedureBlock, SqlRowIdPrivate, SqlTableName = X]
{
Property VALUEA As %Library.String(MAXLEN = 8) [ Required, SqlComputed,SqlColumnumber = 1];
Property VALUEB As %Library.Integer(MAXVAL = 2147483647, MINVAL = -2147483648) [ Required,InitialExpression=0,SqlColumnNumber = 2, SqlComputeCode = {SET {*}=$SEQ(^VALUEB)}, SqlComputeOnChange = %%UPDATE ];
Trigger[Event=Update]{
NEW valuebx
new rowid
set rowid={ID}
SET valuebx= 0
// {fieldname*C} evaluates to 1 if the field has been changed and 0 
if({VALUEA*C}=1){
// we trigger sql computeCode and inc of global variable by update
//and it doesnt matter what is here in :valuebx
&sql(update x set valueb=:valuebx WHERE ROWID=:rowid)
}
}
}

相关内容

  • 没有找到相关文章