database - Creating After Trigger -
i trying build simple database on own time before sql business course starts better understand few concepts since struggling beginner. want create after trigger on hotel table deletes records rooms table match (:old.hotel_id). i've been reading on triggers online, still having trouble understanding how code body of trigger. using oracle since feels more comfortable me in inexperience. hoping community here give me insight on this.
i tried
create trigger tblhotel_t1 after delete on tblhotel each row
and had
delete tblrooms hothotel_id=:old.hothotel_id;
i unsure how enter trigger oracle, since first began using sql studio manager. though oracle seems lot simpler, not use user interface.
then oracle supplies "when" field, , "trigger body" field. become confused because i'm not sure how enter in.
if post you've tried already, showing you're going wrong.
it sounds trigger want like
create or replace trigger trg_hotel_del after delete on hotel each row begin delete rooms hotel_id = :old.hotel_id; end;
i'm assuming goal create trigger fires after delete (it seem odd delete rooms when inserted or updated row in hotel
table).
of course, in reality, create foreign key constraint in order enforce rather creating trigger.
Comments
Post a Comment