Hello Respected members,
This is my first post in dream.in.code.
I am using Oracle 10g.
SQL> create table table1(no varchar2(10),name varchar2(10),check(no like 'ed10[0
-9]'));
Table created.
SQL> insert into table1 values('ed101','r');
insert into table1 values('ed101','r')
*
ERROR at line 1:
ORA-02290: check constraint (SYSTEM.SYS_C004024) violated
I have no clue what is wrong here.
Thank you in advance
Create table with check(column like 'ed10[0-9]')
Page 1 of 12 Replies - 2201 Views - Last Post: 03 September 2012 - 10:54 AM
Replies To: Create table with check(column like 'ed10[0-9]')
#2
Re: Create table with check(column like 'ed10[0-9]')
Posted 02 September 2012 - 10:19 AM
The constraint is checking for [0-9] as a string literal, how about something like this instead?
CREATE TABLE table1( no varchar2(10), name varchar2(10), check(NO LIKE 'ed10_'), CHECK( to_number(SUBSTR(NO,5,1)) <=9 );
#3
Re: Create table with check(column like 'ed10[0-9]')
Posted 03 September 2012 - 10:54 AM
Yes that works.I had come to the conclusion that it is not possible to set such a constraint in oracle
Thank You
Thank You
Page 1 of 1
|
|

New Topic/Question
Reply


MultiQuote



|