Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Conditional Constraint?

Re: Conditional Constraint?

From: DA Morgan <damorgan_at_exesolutions.com>
Date: Mon, 23 Dec 2002 14:33:02 -0800
Message-ID: <3E078F1E.8281DA32@exesolutions.com>


J Alex wrote:

> "DA Morgan" <damorgan_at_exesolutions.com> wrote
> > wing wrote:
> >
> > > Hi,
> > >
> > > I am new in Oracle and have a query on how to add conditional
> > > constraint.
> > >
> > > Say, I have a simple table Demerit with three fields.
> > >
> > > Demerit(DEM_CODE, DEM_DES, POINTS)
> > > where
> > > DEM_CODE (N, 2)
> > > DEM_DES (C, 30)
> > > POINTS (N, 1)
> > >
> > > How to add the following constraint?
> > >
> > > All DEM_CODE should carry an integer POINT between 1 to 6 inclusive,
> > > and DEM_CODE greater than 20 should carry no more than 3 POINT.
> > >
> > > Thanks in advance of any ideas and inputs.
> > >
> > > Wing
> >
> > What you are trying to do requires a trigger.
>
> No, it doesn't. Check constraints work well for this sort of thing. Note
> Jonathon Lewis' post with the constraint.

I missed Jonathan's posting but the request was for:

"All DEM_CODE should carry an integer POINT"

I'd like to see a Check Constraint with an "AND" clause.

Daniel Morgan Received on Mon Dec 23 2002 - 16:33:02 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US