创建新触发器时,我不知道我的问题。 我的语法是否正确?谢谢! Console Logging pane
p / s:当我尝试插入值时,我的控制台显示
CREATE OR REPLACE TRIGGER EX03_3
BEFORE INSERT ON HR.CHITIETDATHANG
FOR EACH ROW
DECLARE
TONGHANG NUMBER; -- Total Items
HANGHIENCO NUMBER; -- Items present
HANGDABAN NUMBER; -- Items was sales.
BEGIN
-- Get total Items
SELECT SUM(MH.SOLUONG) INTO TONGHANG
FROM HR.MATHANG MH;
-- Get total Items was sales
SELECT SUM(CTDH.SOLUONG) INTO HANGDABAN
FROM HR.CHITIETDATHANG CTDH;
-- Items present
HANGHIENCO := TONGHANG - HANGDABAN;
IF(HANGHIENCO >= HANGDABAN) THEN
HANGHIENCO := HANGHIENCO-1;
INSERT INTO HR.CHITIETDATHANG VALUES(:NEW.SOHOADON,:NEW.MAHANG,
:NEW.GIABAN,:NEW.SOLUONG,:NEW.MUCGIAMGIA);
ROLLBACK;
END IF;
NULL;
END;

答案 0 :(得分:0)
似乎有两个严重的错误
1)触发器尝试在HR.CHITIETDATHANG
的插入触发器的主体中插入HR.CHITIETDATHANG
。
2)在insert语句无用之后使用rollback
。
注意:我在这些select语句中看到没有任何相关的提升no_data_found。正如Kaushik Nayak所说,EX03_3和EX04_4感到困惑。