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

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

Re: Conditional Constraint?

From: Howard J. Rogers <howardjr2000_at_yahoo.com.au>
Date: Sun, 22 Dec 2002 16:49:19 +1100
Message-ID: <yecN9.8132$jM5.22524@newsfeeds.bigpond.com>


As soon as you start doing conditional constraints, you're talking business logic. At which point, your attention invariably should turn the way of a before insert and/or before update trigger.

The simple one, that all demerit points should be between 1 and 6 is a check constraint:

create table blah (
col1 number);
alter table blah add (constraint blah_col1_ck check (col1 between 1 and 6));

But as soon as you start wanting to say "if this then that', it's trigger time.

Incidentally, don't cross-post.

Regards
HJR "wing" <wingwong_at_witty.com> wrote in message news:873e96d6.0212211735.4fd633d5_at_posting.google.com...
> 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
Received on Sat Dec 21 2002 - 23:49:19 CST

Original text of this message

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