Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: upper case constraint?
the check constraint will work, but throw an error back to the user. an
alternative uses a trigger
SQL*Plus: Release 9.2.0.4.0 - Production on Thu Feb 12 15:52:34 2004
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
SQL> CREATE TABLE bla
2 (
3 firstname varchar2(10) CHECK(UPPER(firstname) = firstname)
4* );
Table created.
SQL> insert into bla values ('niall');
insert into bla values ('niall')
*
ERROR at line 1:
ORA-02290: check constraint (NIALL.SYS_C003332) violated
SQL> create or replace trigger trg_bla
2 before insert or update on bla
3 for each row
4 begin
5 :new.firstname := UPPER(:new.firstname);
6 end;
7 /
Trigger created.
SQL> insert into bla values ('niall');
1 row created.
SQL> select * from bla
2 ;
FIRSTNAME
-- Niall Litchfield Oracle DBA Audit Commission UK "Thomas Kellerer" <spam_eater_at_gmx.net> wrote in message news:c0g67j$16fkdi$1_at_ID-13919.news.uni-berlin.de...Received on Thu Feb 12 2004 - 09:56:50 CST
>
>
> On 12.02.2004 16:18 D. Alvarado wrote:
>
> > Hello, I'm working with Oracle 8.1.7 for Solaris. Is there any
> > constraint I can put on a VARCHAR2 column to force its characters
> > always be stored as upper case? Thanks - Dave
>
> what about
>
> CREATE TABLE bla
> (
> firstname varchar2(10) CHECK(UPPER(firstname) = firstname)
> );
>
> Haven't tried it though
>
> Thomas
![]() |
![]() |