sql - Oracle Trigger - Condition before insert -
i don't know problem when created new trigger. syntax correct? thanks! console logging pane
p/s: console display when try insert values
create or replace trigger ex03_3 before insert on hr.chitietdathang each row declare tonghang number; -- total items hanghienco number; -- items present hangdaban number; -- items sales. begin -- total items select sum(mh.soluong) tonghang hr.mathang mh; -- total items sales select sum(ctdh.soluong) hangdaban hr.chitietdathang ctdh; -- items present hanghienco := tonghang - hangdaban; if(hanghienco >= hangdaban) hanghienco := hanghienco-1; insert hr.chitietdathang values(:new.sohoadon,:new.mahang, :new.giaban,:new.soluong,:new.mucgiamgia); rollback; end if; null; end;
seem 2 critical mistakes
1) trigger tries insert hr.chitietdathang
in body of insert trigger of hr.chitietdathang
.
2) use rollback
after insert statement useless.
note : can see nothing relevant make raise no_data_found in select statements. ex03_3 , ex04_4 confused, kaushik nayak says.
Comments
Post a Comment