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: Limit characters in a field

Re: Limit characters in a field

From: Rene Nyffenegger <rene.nyffenegger_at_gmx.ch>
Date: 14 Feb 2003 19:20:27 GMT
Message-ID: <b2jfhr$1c9kvj$1@ID-82536.news.dfncis.de>

> Hi all,
> Is there some way to limit WHAT characters can be entered in to a field
> in an Oracle table?
> For eg., allow a field to have ONLY vowels (i.e., the characters
> a,e,i,o,u) and some punctuation marks (like single quotes, comma, double
> quotes, hyphen and a semicolon)?
> Thanks in advance,
> Krishna

Krishna,

In your case of 'only vowels', a check constraint will do:

create table test_ (
  only_vowels varchar2(50) check
   (translate(upper(only_vowels),':AEIOU',':') = ':') );

insert into test_ values ('abc');
insert into test_ values ('io');
insert into test_ values (null);
insert into test_ values ('u');

select * from test_;

drop table test_;

hth

Rene Nyffenegger

-- 
  no sig today
Received on Fri Feb 14 2003 - 13:20:27 CST

Original text of this message

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