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: Can Check Constraints be Reused for Multiple Columns?

Re: Can Check Constraints be Reused for Multiple Columns?

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Mon, 08 Aug 2005 21:59:41 +0200
Message-ID: <b9eff15137jl1htesi03meqemfsj8ij9hn@4ax.com>


On 8 Aug 2005 11:25:27 -0700, "GeoPappas" <PappasG_at_gmail.com> wrote:

>I have a bunch of columns that are a CHAR(1) and should only contain
>"Y" (for Yes) and "N" (for No).
>
>Instead of creating a separate check constraint for each and every
>column, is there a way to set up one check constraint and reuse it for
>multiple columns?

there is not
>
>Or is there a better way of doing this?

You could of course set up a trigger, combining a bunch of

if not (:new.column_name in ('Y','N')) then raise_application_error(<some negative number greater than -20000>,<some descriptive text>);
end if;  

--
Sybrand Bakker, Senior Oracle DBA
Received on Mon Aug 08 2005 - 14:59:41 CDT

Original text of this message

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