Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 9th, 2008, 09:30 AM
jnicolau jnicolau is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 2 jnicolau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 3 sec
Reputation Power: 0
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?

Reply With Quote
  #2  
Old April 10th, 2008, 08:04 AM
LKBrwn_DBA LKBrwn_DBA is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 294 LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 16 h 48 m 15 sec
Reputation Power: 10
Cool

Maybe a trigger after update statement?
__________________

Reply With Quote
  #3  
Old April 10th, 2008, 09:29 AM
jnicolau jnicolau is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 2 jnicolau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 3 sec
Reputation Power: 0
Quote:
Originally Posted by LKBrwn_DBA
Maybe a trigger after update statement?


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.

Reply With Quote
  #4  
Old April 10th, 2008, 09:42 AM
LKBrwn_DBA LKBrwn_DBA is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 294 LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level)LKBrwn_DBA User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 16 h 48 m 15 sec
Reputation Power: 10
Cool

Quote:
Originally Posted by jnicolau
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.


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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Constraint sum validation


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT