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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Can't figure out why this has an error?

Re: Can't figure out why this has an error?

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: 5 Mar 2004 06:40:23 -0800
Message-ID: <2687bb95.0403050640.7df58c4f@posting.google.com>


vabru4u_at_yahoo.com (Vishal) wrote in message news:<3fc78ae.0403042351.79b28eac_at_posting.google.com>...
> create table ITEMS
> (
> ITEMID number constraint ITEM_PK primary key,
> ITEMDESC varchar2(300),
> ICAT number constraint FK_ITEM_CAT references CATEGORY,
> PRICE number(9,2) constraint PRICE_CHECK check (price not null and price > 10),
>
> SOLD char(1) constraint check (sold not null and sold in ('Y', 'N')
>
> );
>
> I get the following error:
>
> PRICE number(9,2) constraint PRICE_CHECK check (price not null and price > 10),
> *
> ERROR at line 6:
> ORA-00920: invalid relational operator
>
> Any ideas? Thanks!

Obviously, you should check the syntax for a check constraint using the SQL manual:

@UT1 SQL>> create table ITEMS
  2 (
  3 ITEMID number constraint ITEM_PK primary key   4 ,ITEMDESC varchar2(300)
  5 ,ICAT number constraint FK_ITEM_CAT references CATEGORY

  6  ,PRICE     number(9,2)       constraint PRICE_CK
  7                               check ( price is not null and price

> 10)
8 ,SOLD char(1) constraint SOLD_CK 9 check (sold is not null and sold in
('Y','N') )
 10 );

Table created.

You could have written ,price number(9,2) not null constraint price_ck check (price > 10).

HTH -- Mark D Powell -- Received on Fri Mar 05 2004 - 08:40:23 CST

Original text of this message

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