Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > Oracle
| Search | Today's Posts | Mark Forums Read
Oracle General Oracle database discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Oracle section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 5th, 2011, 05:25 AM
Authorized User
Points: 350, Level: 6
Points: 350, Level: 6 Points: 350, Level: 6 Points: 350, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: , , Pakistan.
Posts: 54
Thanks: 8
Thanked 1 Time in 1 Post
Default Can we use any other operator than relational operators for 'CONSTRAINT', because I a

Can we use logical operators, Conditional operators other than relational operator in query of Constraints?, because I am having an error

Below is the query I tried


Alter table arbab ADD CONSTRAINT abc CHECK (gender 'Male' or 'female');

I am having below mentioned error:

Error starting at line 1 in command:
Alter table arbab ADD CONSTRAINT abc CHECK (gender 'Male' or 'female')
Error report:
SQL Error: ORA-00920: invalid relational operator
00920. 00000 - "invalid relational operator"
*Cause:
*Action:


This query:

Alter table arbab ADD CONSTRAINT abc CHECK (gender >10);


Worked fine.

Thanks in advance.
__________________
How to do programming?
 
Old April 5th, 2011, 06:59 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Try:

Code:
alter table arbab
add constraint ck_abc
check (gender in ('MALE', 'FEMALE'));
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.
The Following User Says Thank You to om_prakash For This Useful Post:
 
Old April 11th, 2011, 06:46 AM
Authorized User
Points: 350, Level: 6
Points: 350, Level: 6 Points: 350, Level: 6 Points: 350, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2008
Location: , , Pakistan.
Posts: 54
Thanks: 8
Thanked 1 Time in 1 Post
Default Thanks

@om_prakash: Thanks your query is working fine, but the query below also worked for that:

Alter table arbab
ADD CONSTRAINT CHKGENDER123 CHECK(GENDER='Male' OR GENDER='Female')
__________________
How to do programming?
 
Old April 12th, 2011, 12:45 AM
Authorized User
 
Join Date: Nov 2006
Location: Bangalore, Karnataka, India.
Posts: 31
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via ICQ to debasisdas Send a message via AIM to debasisdas
Default

What if you have to check the values in the column in a lsit of 10 or more values. How many times you will write OR OR OR ....?

That is the reason the values are check with IN (.,.,...) operator.
__________________
Regards
Debasis
The Following User Says Thank You to debasisdas For This Useful Post:
arbab (April 13th, 2011)




Similar Threads
Thread Thread Starter Forum Replies Last Post
Logical operators ksskumar XSLT 3 November 11th, 2011 06:09 AM
Invalid operator for data type. Operator equals di Pusstiu SQL Server 2000 2 August 10th, 2007 04:51 AM
Math operators nguyendh BOOK: Ivor Horton's Beginning Visual C++ 2005 1 June 25th, 2006 01:35 AM
Matrix operators Ravel99 Pro VB 6 0 April 28th, 2006 03:45 AM
non-relational database Michel SQL Server 2000 4 February 21st, 2006 04:05 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.