Home » SQL & PL/SQL » SQL & PL/SQL » CREATE TABLE/CONSTRAINT PROBLEM
CREATE TABLE/CONSTRAINT PROBLEM [message #18867] Tue, 19 February 2002 05:54 Go to next message
Dave Rolfe
Messages: 4
Registered: February 2002
Junior Member
I am trying to create the Table Offer with the following statement:

create table Offer
(offercode char(3) CONSTRAINT check_offer_start_date
check(NOT EXISTS(select offercode from Offer where offer_date between
add_months(sysdate,-6) and sysdate)),
offer_date date not null,
price number(5,2),
num_sold varchar(5) not null,
primary key (offercode,offer_date),
foreign key (offercode) references offer_details(offercode));

This is giving me the error : ORA-02251: subquery not allowed here

Am i confusing my SQL92 and Oracle SQL here?
If not how can i ALTER a table or CREATE a table using this constraint?

Many Thanks

David Rolfe
Re: CREATE TABLE/CONSTRAINT PROBLEM [message #18868 is a reply to message #18867] Tue, 19 February 2002 06:18 Go to previous message
pratap kumar tripathy
Messages: 660
Registered: January 2002
Senior Member
The check constraint can not query to refer to values in other rows.

so if u want to impose this restriction, then you have to write trigger for that.
Previous Topic: Outer Joins
Next Topic: Need Newest Record From Each ID Group
Goto Forum:
  


Current Time: Thu Mar 28 18:55:48 CDT 2024