Re: Limit characters in a field

From: Vladimir M. Zakharychev <bob_at_dpsp-yes.com>
Date: Mon, 17 Feb 2003 18:40:15 +0300
Message-ID: <b2qvsd$9t4$1_at_babylon.agtel.net>


TRANSLATE() is to the rescue:

SQL> create table ck (
  2 val varchar2(100) CHECK (translate(val,'xaAeEiIoOuU'',"-;','x') IS NULL)   3 )
  4 /

Table created.

SQL> insert into ck values('aaeoui-aa,oui;');

1 row created.

SQL> insert into ck values('this will fail'); insert into ck values('this will fail')
*
ERROR at line 1:
ORA-02290: check constraint (SCOTT.SYS_C0057774) violated

-- 
Vladimir Zakharychev (bob_at_dpsp-yes.com)                http://www.dpsp-yes.com
Dynamic PSP(tm) - the first true RAD toolkit for Oracle-based internet applications.
All opinions are mine and do not necessarily go in line with those of my employer.


"Krishna Vellakkat" <vkrishna_at_siu.edu> wrote in message news:3E4D17ED.81F04336_at_siu.edu...

> 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
Received on Mon Feb 17 2003 - 16:40:15 CET

Original text of this message