Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Can Check Constraints be Reused for Multiple Columns?
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 DBAReceived on Mon Aug 08 2005 - 14:59:41 CDT