DROP TABLE a CASCADE CONSTRAINTS;
CREATE TABLE a(
cyear VARCHAR2(4));
CREATE TRIGGER current_year
BEFORE INSERT ON cyear
FOR EACH ROW SET NEW.year = year(NOW());
修改
我试过了,
CREATE TRIGGER current_year
BEFORE INSERT ON a
FOR EACH ROW
BEGIN
:NEW.cyear = TO_CHAR(SYSDATE, 'YYYY');
END current_year;
我一直收到PLS-00103错误。
答案 0 :(得分:1)
SET
NOW
的内置函数
NEW
和OLD
只能在WHEN
子句中访问;在其他地方,它们应该以冒号(:NEW
,:OLD
)END
个关键字(以及触发器正文开头的BEGIN
)