|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Constraint sum validation
How to validate a sum of some records in a table to be exact value?
I want to guarantee that sum(val_column)=100 at database level. Check constraints out of question. Trigger before update statement disable any update to that column when incrementing one row and decrement another... (unless with forall...) Any other chances? |
|
#2
|
|||
|
|||
|
Maybe a trigger after update statement?
![]()
__________________
|
|
#3
|
|||
|
|||
|
Quote:
before or after update is the same problem... is not possible update two rows, one after another, incrementing the first row and decrementing de second. The trigger will raise on first update because the sum is not 100 at that moment. |
|
#4
|
|||
|
|||
|
Quote:
Which means you cannot implement an "allways sum=100" constraint by transaction, you will have to audit the table at the end of a series of transactions to verify sum=100. ![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Constraint sum validation |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|