Return-Path: <root@fatcity.cts.com>
Received: from ensim.rackshack.net (root@localhost)
 by orafaq.net (8.11.6/8.11.6) with ESMTP id h0UL86v25526
 for <oracle-l@orafaq.net>; Thu, 30 Jan 2003 15:08:06 -0600
X-ClientAddr: 209.68.248.164
Received: from newsfeed.cts.com (newsfeed.cts.com [209.68.248.164])
 by ensim.rackshack.net (8.11.6/8.11.6) with ESMTP id h0UL86m25520
 for <oracle-l@orafaq.net>; Thu, 30 Jan 2003 15:08:06 -0600
Received: from fatcity.UUCP (uucp@localhost)
 by newsfeed.cts.com (8.9.3/8.9.3) with UUCP id JAA18590;
 Thu, 30 Jan 2003 09:51:17 -0800 (PST)
Received: by fatcity.com (26-Feb-2001/v1.0g-b72/bab) via UUCP id 0053EDA5; Thu, 30 Jan 2003 08:34:29 -0800
Message-ID: <F001.0053EDA5.20030130083429@fatcity.com>
Date: Thu, 30 Jan 2003 08:34:29 -0800
To: Multiple recipients of list ORACLE-L <ORACLE-L@fatcity.com>
X-Comment: Oracle RDBMS Community Forum
X-Sender: "Jamadagni, Rajendra" <Rajendra.Jamadagni@espn.com>
Sender: root@fatcity.com
Reply-To: ORACLE-L@fatcity.com
Errors-To: ML-ERRORS@fatcity.com
From: "Jamadagni, Rajendra" <Rajendra.Jamadagni@espn.com>
Subject: RE: Restricting the range of values in a field
Organization: Fat City Network Services, San Diego, California
X-ListServer: v1.0g, build 72; ListGuru (c) 1996-2001 Bruce A. Bergman
Precedence: bulk
Mime-Version: 1.0
Content-Type: multipart/mixed;	boundary="----=_NextPartTM-000-f5c2285f-858a-4a30-ae15-b85784ae4589"
------=_NextPartTM-000-f5c2285f-858a-4a30-ae15-b85784ae4589
Content-Type: multipart/alternative;
 boundary="----_=_NextPart_001_01C2C87D.4835FC80"
------_=_NextPart_001_01C2C87D.4835FC80
Content-Type: text/plain;
 charset="iso-8859-1"

create or replace trigger my_restrictions on
my_table after insert or update as
declare
   unacceptable_values exception;
begin
  begin
   if :new.my_restricted_column not in ('Blah1','blah2','Blah3') then
      --- Grrr .. user errored
      spank_user;
      raise unacceptable_values;
   end if;
  end;
  exception
    when unacceptable_values then
       raise_application_error(20001,'You entered incorrect values, go spank
yourself.');
    when others then
       raise;
end;
/


this should pretty much handle it for you ... don't take this code at its
face value, there could be syntactic errors .. I just wrote on the fly.

Raj
______________________________________________________
Rajendra Jamadagni		MIS, ESPN Inc.
Rajendra dot Jamadagni at ESPN dot com
Any opinion expressed here is personal and doesn't reflect that of ESPN Inc.

QOTD: Any clod can have facts, but having an opinion is an art!


-----Original Message-----
Sent: Thursday, January 30, 2003 11:01 AM
To: Multiple recipients of list ORACLE-L


Is there any way you can specify that the only permissible values (is it
called a domain?) that can be entered in varchar2 field in an Oracle
table to, for example, A, B and C?

We can restrict what values users can enter at the application level,
but it would be nice to be able to also restrict what can be entered at
the database level, in case other means of entering data are ever used
or if the application layer fails, for whatever reason, to trap an
unwanted value.


Thanks

-- 
Aidan Whitehall <aidanwhitehall@fairbanks.co.uk>
Macromedia ColdFusion Developer
Fairbanks Environmental Ltd  +44 (0)1695 51775

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Aidan Whitehall
  INET: AidanWhitehall@Fairbanks.co.uk

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

------_=_NextPart_001_01C2C87D.4835FC80
Content-Type: text/html;
 charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2654.19">
<TITLE>RE: Restricting the range of values in a field</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>create or replace trigger my_restrictions on</FONT>
<BR><FONT SIZE=3D2>my_table after insert or update as</FONT>
<BR><FONT SIZE=3D2>declare</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp; unacceptable_values exception;</FONT>
<BR><FONT SIZE=3D2>begin</FONT>
<BR><FONT SIZE=3D2>&nbsp; begin</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp; if :new.my_restricted_column not in =
('Blah1','blah2','Blah3') then</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --- Grrr .. user =
errored</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; spank_user;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; raise =
unacceptable_values;</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp; end if;</FONT>
<BR><FONT SIZE=3D2>&nbsp; end;</FONT>
<BR><FONT SIZE=3D2>&nbsp; exception</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; when unacceptable_values =
then</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
raise_application_error(20001,'You entered incorrect values, go spank =
yourself.');</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp; when others then</FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; raise;</FONT>
<BR><FONT SIZE=3D2>end;</FONT>
<BR><FONT SIZE=3D2>/</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>this should pretty much handle it for you ... don't =
take this code at its face value, there could be syntactic errors .. I =
just wrote on the fly.</FONT></P>

<P><FONT SIZE=3D2>Raj</FONT>
<BR><FONT =
SIZE=3D2>______________________________________________________</FONT>
<BR><FONT SIZE=3D2>Rajendra Jamadagni&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MIS, ESPN Inc.</FONT>
<BR><FONT SIZE=3D2>Rajendra dot Jamadagni at ESPN dot com</FONT>
<BR><FONT SIZE=3D2>Any opinion expressed here is personal and doesn't =
reflect that of ESPN Inc. </FONT>
<BR><FONT SIZE=3D2>QOTD: Any clod can have facts, but having an opinion =
is an art!</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: Aidan Whitehall [<A =
HREF=3D"mailto:AidanWhitehall@Fairbanks.co.uk">mailto:AidanWhitehall@Fai=
rbanks.co.uk</A>]</FONT>
<BR><FONT SIZE=3D2>Sent: Thursday, January 30, 2003 11:01 AM</FONT>
<BR><FONT SIZE=3D2>To: Multiple recipients of list ORACLE-L</FONT>
<BR><FONT SIZE=3D2>Subject: Restricting the range of values in a =
field</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>Is there any way you can specify that the only =
permissible values (is it</FONT>
<BR><FONT SIZE=3D2>called a domain?) that can be entered in varchar2 =
field in an Oracle</FONT>
<BR><FONT SIZE=3D2>table to, for example, A, B and C?</FONT>
</P>

<P><FONT SIZE=3D2>We can restrict what values users can enter at the =
application level,</FONT>
<BR><FONT SIZE=3D2>but it would be nice to be able to also restrict =
what can be entered at</FONT>
<BR><FONT SIZE=3D2>the database level, in case other means of entering =
data are ever used</FONT>
<BR><FONT SIZE=3D2>or if the application layer fails, for whatever =
reason, to trap an</FONT>
<BR><FONT SIZE=3D2>unwanted value.</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>Thanks</FONT>
</P>

<P><FONT SIZE=3D2>-- </FONT>
<BR><FONT SIZE=3D2>Aidan Whitehall =
&lt;aidanwhitehall@fairbanks.co.uk&gt;</FONT>
<BR><FONT SIZE=3D2>Macromedia ColdFusion Developer</FONT>
<BR><FONT SIZE=3D2>Fairbanks Environmental Ltd&nbsp; +44 (0)1695 =
51775</FONT>
</P>

<P><FONT =
SIZE=3D2>_______________________________________________________________=
_________</FONT>
<BR><FONT SIZE=3D2>This e-mail has been scanned for all viruses by Star =
Internet. The</FONT>
<BR><FONT SIZE=3D2>service is powered by MessageLabs. For more =
information on a proactive</FONT>
<BR><FONT SIZE=3D2>anti-virus service working around the clock, around =
the globe, visit:</FONT>
<BR><FONT SIZE=3D2><A HREF=3D"http://www.star.net.uk" =
TARGET=3D"_blank">http://www.star.net.uk</A></FONT>
<BR><FONT =
SIZE=3D2>_______________________________________________________________=
_________</FONT>
<BR><FONT SIZE=3D2>-- </FONT>
<BR><FONT SIZE=3D2>Please see the official ORACLE-L FAQ: <A =
HREF=3D"http://www.orafaq.net" =
TARGET=3D"_blank">http://www.orafaq.net</A></FONT>
<BR><FONT SIZE=3D2>-- </FONT>
<BR><FONT SIZE=3D2>Author: Aidan Whitehall</FONT>
<BR><FONT SIZE=3D2>&nbsp; INET: AidanWhitehall@Fairbanks.co.uk</FONT>
</P>

<P><FONT SIZE=3D2>Fat City Network Services&nbsp;&nbsp;&nbsp; -- =
858-538-5051 <A HREF=3D"http://www.fatcity.com" =
TARGET=3D"_blank">http://www.fatcity.com</A></FONT>
<BR><FONT SIZE=3D2>San Diego, =
California&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- Mailing list =
and web hosting services</FONT>
<BR><FONT =
SIZE=3D2>---------------------------------------------------------------=
------</FONT>
<BR><FONT SIZE=3D2>To REMOVE yourself from this mailing list, send an =
E-Mail message</FONT>
<BR><FONT SIZE=3D2>to: ListGuru@fatcity.com (note EXACT spelling of =
'ListGuru') and in</FONT>
<BR><FONT SIZE=3D2>the message BODY, include a line containing: UNSUB =
ORACLE-L</FONT>
<BR><FONT SIZE=3D2>(or the name of mailing list you want to be removed =
from).&nbsp; You may</FONT>
<BR><FONT SIZE=3D2>also send the HELP command for other information =
(like subscribing).</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C2C87D.4835FC80--


------=_NextPartTM-000-f5c2285f-858a-4a30-ae15-b85784ae4589
Content-Type: text/plain;
 name="ESPN_Disclaimer.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="ESPN_Disclaimer.txt"

*********************************************************************This e-mail message is confidential, intended only for the named recipient(s) above and may contain information that is privileged, attorney work product or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 and delete this e-mail message from your computer, Thank you.*********************************************************************1

------=_NextPartTM-000-f5c2285f-858a-4a30-ae15-b85784ae4589--

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.net
-- 
Author: Jamadagni, Rajendra
  INET: Rajendra.Jamadagni@espn.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

