我在数据库中有一组表。它们的语法是:
CREATE TABLE Concert
(concert_id NUMBER (3) NOT NULL,
concert_name VARCHAR (14) NOT NULL,
concert_duration NUMBER (1) NOT NULL,
concert_type VARCHAR (10) NOT NULL,
artist VARCHAR (14) NOT NULL,
concert_cost NUMBER (3) NOT NULL
);
CREATE TABLE Customer
(customer_id NUMBER (4) NOT NULL,
firstname VARCHAR (14) NOT NULL,
lastname VARCHAR (14) NOT NULL,
gender VARCHAR (1) NOT NULL,
street VARCHAR (14),
city VARCHAR (14),
country VARCHAR (14),
postcode VARCHAR (8) NOT NULL
);
CREATE TABLE Event
(event_id NUMBER (3) NOT NULL,
event_date DATE NOT NULL,
venue_id NUMBER (2) NOT NULL,
concert_id NUMBER (3) NOT NULL
);
CREATE TABLE Venue
(venue_id NUMBER (2) NOT NULL,
venue_name VARCHAR (14) NOT NULL,
max_capacity NUMBER (5) NOT NULL,
street VARCHAR (14),
city VARCHAR (14),
country VARCHAR (14),
postcode VARCHAR (8) NOT NULL
);
CREATE TABLE Booking
(arrival_time VARCHAR (8) default to_char(localtimestamp,'HH:MI') check(arrival_time like '__:___AM' or arrival_time like '__:___PM'),
vehicle_no VARCHAR (8),
evaluation NUMBER (1) NOT NULL CONSTRAINT ck_evaluation CHECK (evaluation BETWEEN 0 AND 5),
event_id NUMBER (3) NOT NULL,
customer_id NUMBER (4) NOT NULL
);
Concert_id 和venue_id 是事件表中的外键。Event_id 和 customer_id 也是预订表中的外键。我想创建一个触发器,它将名字和姓氏(来自客户表)、concert_name(来自音乐会表)、event_date(来自事件表)、场地名称(来自场地表)和评估(来自预订表)放入和审计表中如果客户给出零评价。我已将审计表创建为:
CREATE TABLE audit_evaluation
(firstname VARCHAR (14),
lastname VARCHAR (14),
concert_name VARCHAR (14),
event_date DATE,
venue_name (14),
evaluation NUMBER (1)
);
我试图用这种语法创建触发器,但它给出了一个错误:
CREATE OR REPLACE TRIGGER trg_evaluation
AFTER INSERT ON booking
FOR EACH ROW
BEGIN
IF (evaluation = 0)
THEN
INSERT INTO audit_evaluation (firstname, lastname, concert_name, event_date, venue_name, evaluation)
VALUES (customer.firstname, customer.lastname, concert.concert_name, event.event_date, venue.venue_name, booking.evaluation);
END IF;
END;
请帮忙!!!