如何设置表中的行集的约束 [英] How Do I Set A Contraints For Set Of Rows In Table
本文介绍了如何设置表中的行集的约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在我正在创建一个使用oracle
的会计软件,其中一个主要表是日记本,我创建了所有报告等。
结构是这样的
id slno acc_id amount
1 st trans
1 1 1 500
1 2 27 -500
< br $>
second trans
2 1 15 700
2 2 14 - 100
2 3 28 -400 >
2 4 90 -200
i必须检查交易金额是否为零
是否可以在oracle中设置任何约束或任何其他方式
推荐答案
您无法创建此类约束在这种情况下你不能使用触发器,因为检查已修改的同一个表会导致ORA-04091。
一种可能性是使用sto包含检查的红色程序,如果总和不是零,则会引发错误。然后,所有修改都应通过此过程。
You can't create such constraint and in this case you can't use triggers since examining the same table that has been modified would cause a ORA-04091.
One possibility is to use a stored procedure which would contain the check and if the sum is anything other than zero an error would be raised. All modifications should then go through this procedure.
这篇关于如何设置表中的行集的约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文