你可以使用存储过程,或触发器。 比如你有这样一个存储过程produrce insert and replace 过程1(字段1 as 类型,字段2 as 类型,字段3 as 类型,...) as ...定义一些变量 d... begin x=//几个字段的算法 repalce xxx set 字段一 字段二 , .... , x where ID=... end
to txinfo: 是的,怎样办?
在TDataSet中有一个叫BeforePost的事件你可以在里面写aa=(this as TDataSet).FieldByName("xx").Value; bb=(this as TDataSet).FieldByName("yy").Value; (this as TDataSet).FieldByName("zz").Value=计算公式函数(aa,bb);方法很多的,不光是一种。 :)
当A改动时B的值自动也跟着变化,
保存时把A和B都保存到数据库里?
比如你有这样一个存储过程produrce insert and replace 过程1(字段1 as 类型,字段2 as 类型,字段3 as 类型,...) as ...定义一些变量
d... begin
x=//几个字段的算法
repalce xxx
set
字段一
字段二
,
....
,
x
where ID=...
end
bb=(this as TDataSet).FieldByName("yy").Value;
(this as TDataSet).FieldByName("zz").Value=计算公式函数(aa,bb);方法很多的,不光是一种。
:)