我想创建一个触发器来计算 Event 表上的 totalPayment。但是为了计算 totalPayment 列,它引用了另外两个表,即 Location 和 Equipment。下面是表的表结构:
create table equipment(
equipmentID varchar2(10) primary key,
equipmentName varchar2(50) not null,
equipmentPriceUnit decimal(18,2) not null
);
create table location(
locationID varchar2(10) primary key,
locationName varchar2(50) not null,
locationMaxCapacity int not null,
locationPriceHour decimal(18,2) not null
);
create table event(
eventID varchar2(10) primary key,
eventName varchar2(50) not null,
eventDurationHour int not null,
noAudience int not null,
equipmentID references equipment(equipmentID) null,
equipmentQuantity int null,
locationID references location(locationID) null,
**totalPayment decimal(18,2) null**
);
进行此计算的方程式是
totallocation := locationPriceHour*eventDurationHour;
totalequipment := equipmentPriceUnit*equipmentQuantity;
totalPayment :=totallocation + totalequipment;