Create Trigger AddUserSessionDate AFTER INSERT ON Usersession
REFERENCING NEW AS NEW
FOR EACH ROW Mode DB2SQL
UPDATE NEW SET NEW.session_date = CURRENT_DATE;
我正在尝试创建一个触发器,以便在每次插入行时填充当前日期。除了Derby documentation中的三个以外,我找不到其他许多例子。我在这个例子之后建立了这个声明
CREATE TRIGGER FLIGHTSDELETE3
AFTER DELETE ON FLIGHTS
REFERENCING OLD AS OLD
FOR EACH ROW MODE DB2SQL
DELETE FROM FLIGHTAVAILABILITY WHERE FLIGHT_ID = OLD.FLIGHT_ID;
但我得到
Error code 30000, SQL state 42X05: Table/View 'NEW' does not exist.
我做错了什么?
答案 0 :(得分:2)
我会使用DEFAULT
代替触发器:
CREATE TABLE Usersession (
session_date column_type DEFAULT CURRENT_DATE
,...
)