Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > IBM DB2 > Re: How to avoi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 11 Topic 9082 of 9257
Post > Topic >>

Re: How to avoid 2nd trigger

by Lennart <Erik.Lennart.Jonsson@[EMAIL PROTECTED] > Jul 14, 2008 at 09:32 AM

On Jul 14, 5:02 pm, "lenygold via DBMonster.com" <u41482@[EMAIL PROTECTED]
> wrote:
> Thank you Lennart.
> I like this approach.
> One more question. What if  you  a manager or superviser then
commissions
> always should be zero and education level more then 10.

In general, DB2 does not sup****t sub selects in check constraints, but
as long as the rule regards a relation****p between columns in the same
row, it is a good candidate for a check constraint (it is not possible
at all times though). If I understand your table this case should be
something like (I assume supervisor and manager belongs to the JOB
domain) :

ALTER TABLE EMP_SCREEN_EDIT ADD CONSTRAINT <NAME>
    CHECK (  NOT ( JOB IN ('manager', 'superviser')) OR ( COMM = 0 AND
EDLEVEL > 10 ) )

If you are a manager or supervisor, [ NOT ( JOB IN ('manager',
'superviser')) ] evaluates to FALSE, hence [ (commissions = 0 AND
EDLEVEL > 10 ) ] must evaluate to TRUE for the constraint to evaluate
to TRUE.

A number of the attributes in the table are nullable and you have to
be extra careful with these (but that holds whether you put them in a
trigger or in a constraint). For example, what does it mean if COMM is
null, is that ok for a supervisor?


/Lennart
 




 11 Posts in Topic:
How to avoid 2nd trigger
"lenygold via DBMons  2008-07-13 22:07:01 
Re: How to avoid 2nd trigger
Lennart <Erik.Lennart.  2008-07-14 00:00:13 
Re: How to avoid 2nd trigger
"lenygold via DBMons  2008-07-14 11:05:57 
Re: How to avoid 2nd trigger
Lennart <Erik.Lennart.  2008-07-14 05:24:44 
Re: How to avoid 2nd trigger
"lenygold via DBMons  2008-07-14 13:28:59 
Re: How to avoid 2nd trigger
Lennart <Erik.Lennart.  2008-07-14 07:13:34 
Re: How to avoid 2nd trigger
"lenygold via DBMons  2008-07-14 15:02:53 
Re: How to avoid 2nd trigger
Lennart <Erik.Lennart.  2008-07-14 09:32:06 
Re: How to avoid 2nd trigger
Lennart <Erik.Lennart.  2008-07-14 09:44:45 
Re: How to avoid 2nd trigger
"lenygold via DBMons  2008-07-14 17:10:17 
Re: How to avoid 2nd trigger
"lenygold via DBMons  2008-07-14 17:41:51 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Sep 5 6:44:23 CDT 2008.