create or replace TRIGGER TRG_DecreaseQuantity
AFTER INSERT
ON V_SALE FOR EACH ROW
BEGIN
UPDATE VEHICLE
SET V.V_QUANTITY=(SELECT CASE
WHEN V.V_QUANTITY >= S.QUANTITY AND
V.VEHICLE_ID = S.VEHICLE_ID_FK
THEN V.V_QUANTITY = V.V_QUANTITY-S.QUANTITY
WHEN V.V_QUANTITY < S.QUANTITY
THEN V.V_QUANTITY = S.QUANTITY
FROM VEHICLE V,
V_SALE S
WHERE V.VEHICLE_ID=S.VEHICLE_ID_FK
)
WHERE V.VEHICLE_ID = :NEW.VEHICLE_ID_FK;
END;
我们有一个autoGallery
数据库,其中有表。有两个表V_SALE
必须VEHICLE
控制。当我出售车辆时,我想控制车辆的数量,然后减少或不减少数量。
Vehicle(
Vehicle_ID Primary key,
V_QUANTITY
...
)
V_SALE(
VEHICLE_ID_FK FOREIGN KEY,
QUANTITY
...
)
我收到以下错误:
Compilation failed, line 5 (16:03:48) The line numbers associated with compilation errors are relative to the first BEGIN statement. This only affects the compilation of database triggers.
PL/SQL: ORA-00905: missing keyword
Compilation failed, line 2 (16:03:48) The line numbers associated with compilation errors are relative to the first BEGIN statement. This only affects the compilation of database triggers.
PL/SQL: SQL Statement ignored