I have difficulties to grasp the trigger concept, or to be perfectly clear, the way to use it in my case.
Here's my CREATE so far :
CREATE TABLE Station
(
nomStation VARCHAR2(100),
capacite NUMBER(5) NOT NULL,
lieu VARCHAR2(100) NOT NULL,
region VARCHAR2(100),
tarif NUMBER(6,2) DEFAULT 0,
PRIMARY KEY (nomStation),
CONSTRAINT UC_lieu_region UNIQUE (lieu, region),
CONSTRAINT regionUnique CHECK ( region='Ocean Indien' OR
region='Antilles' OR
region='Europe' OR
region='Ameriques' OR
region='Extreme Orient')
);
CREATE TABLE Activite
(
nomStation VARCHAR2(100),
libelle VARCHAR2(100),
prix NUMBER(6,2) DEFAULT 0,
CONSTRAINT PK_nomStation_libelle PRIMARY KEY (nomStation, libelle),
CONSTRAINT FK_nomStation FOREIGN KEY (nomStation) REFERENCES Station(nomStation) ON DELETE CASCADE
);
What I want to achieve is a constraint on Station.tarif and Activite.prix .
Activite.prix < Station.tarif && Activite.prix > 0
So naturally I tried this :
CONSTRAINT CH_prix CHECK (prix<(SELECT tarif FROM Station)),
But I get the subquery error. Now I understand that I have the same issue as this topic : Using subquery in a Check statement in Oracle
Which is cool, but unfortunately, I'm a rookie and I don't see how a trigger can help me…
Anyone?