Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Check constraint for hexadecimal values

Re: Check constraint for hexadecimal values

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Fri, 20 Jul 2007 06:22:38 +0200
Message-ID: <46a0388b$0$7615$426a74cc@news.free.fr>

<red_valsen_at_yahoo.com> a écrit dans le message de news: 1184882576.408827.91680_at_o61g2000hsh.googlegroups.com...
| I've attempted to create a check constraint on a column which will
| contain up to 8 individual hexadecimal values (e.g., "FF1C3D0A", etc.)
| like so:
|
| create table bla(
| .
| .
| column hexvalue char(8)
| check (hexvalue in ('a-f''A-F''0-9')),
| .
| .
| )
|
| -- but the syntax is incorrect. What will work? Do I need a regular
| expression? Use 'like'?
|
| The requirements for check constraints are rather severe, so I'm
| beginning to doubt that I can do this.
|

SQL> create table t (
  2 hexvalue varchar2(8)
  3 check (to_number(hexvalue,'XXXXXXXX')<to_number('100000000','XXXXXXXXX'))   4 )
  5 /

Table created.

Regards
Michel Cadot Received on Thu Jul 19 2007 - 23:22:38 CDT

Original text of this message

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