Home » SQL & PL/SQL » SQL & PL/SQL » What is problem with Check Constraint
What is problem with Check Constraint [message #210797] Fri, 22 December 2006 07:32 Go to next message
impemp
Messages: 3
Registered: December 2006
Location: india
Junior Member
Hi friends,
When i am trying to create table with following code, problem comes as follows:

create table pop(pid number,pname varchar2(10),cat varchar2(10),age number(3) check(case cat when age<21 then 'Minor'
2 when (age>21 or age=21) then 'Major'));

create table pop(pid number,pname varchar2(10),cat varchar2(10),age number(3) check(case cat when age<21 then 'Minor'
when (age>21 or age=21) then 'Major'))

ORA-00905: missing keyword

can you help me to resolve this.

[Updated on: Fri, 22 December 2006 07:33]

Report message to a moderator

Re: What is problem with Check Constraint [message #210814 is a reply to message #210797] Fri, 22 December 2006 08:26 Go to previous messageGo to next message
rameshuddaraju
Messages: 69
Registered: June 2005
Location: India
Member

when age<21 then 'Minor'

There is no clarity in your check condition. What do you want to do with check statement.
Re: What is problem with Check Constraint [message #210817 is a reply to message #210797] Fri, 22 December 2006 08:32 Go to previous messageGo to next message
scorpio_biker
Messages: 154
Registered: November 2005
Location: Kent, England
Senior Member
Hi,

I think you are missing the word constraint in your create table statement.

See here

[Updated on: Fri, 22 December 2006 08:32]

Report message to a moderator

Re: What is problem with Check Constraint [message #210853 is a reply to message #210797] Fri, 22 December 2006 11:56 Go to previous message
ab_trivedi
Messages: 460
Registered: August 2006
Location: Pune, India
Senior Member
hi impemp,

you can add this functionality with creating trigger. While creating the table you want to give the condition and value to one column.

Try trigger to implement this business rule.

Bye
Ashu
Previous Topic: Using Case within a Function
Next Topic: how to treat char(30) as space-delimited number?
Goto Forum:
  


Current Time: Sat Dec 03 04:08:41 CST 2016

Total time taken to generate the page: 0.09301 seconds