我需要你们的帮助。我正在使用oracle apex for university,我的任务是创建触发器。我很难创建它们,我甚至不知道这个触发器有什么问题。有人能帮助我吗?
我收到错误
Encountered the symbol "SELECT" when expecting one of the following: ( - + case mod new not null <an identifier> <a double-quoted delimited-identifier> <a bind variable> continue avg count current exists max min prior sql stddev sum variance execute forall merge time timestamp interval date <a string literal with character set specification> <a number> <a single-quoted SQL string> pipe <an alternatively-quoted string literal with character set specification> <an alternat
Error at line 3: PLS-00049: bad bind variable 'NEW'
Error at line 3: PLS-00103: Encountered the symbol "" when expecting one of the following: . ( * @ % & = - + ; < / > at for in is mod remainder not rem <an exponent (**)> <> or != or ~= >= <= <> and or like like2 like4 likec between group having intersect minus order start union where connect || indicator multiset member submultiset
Error at line 3: PLS-00049: bad bind variable 'CONTRACT' Error at line 3: PLS-00049: bad bind variable 'CONTRACT' -
CREATE OR REPLACE TRIGGER restrict_orders
BEFORE INSERT ON orders
FOR EACH ROW
BEGIN
DECLARE countOrders number;
set countOrders := SELECT count(contract) FROM orders WHERE :new:contract := old:contract AND (:old.status := 'PREPARING' OR :old.status := 'IN PROGRESS');
IF (countOrders :> 3)
THEN
RAISE_APPLICATION_ERROR (-20202, 'You have too much active orders.');
END IF;
END;
2条答案
按热度按时间icnyk63a1#
相当多的错误;看看这个有没有帮助。
样表:
触发器:
测试:
型
Kind of works.然而,注意如果你试图一次插入多行,它会失败,因为table会发生 mutating(所以你必须采取另一种更复杂的方法),但是-如果你一次只插入一行,你就可以了:
uyhoqukh2#
你需要更正你的语法应该是-