database - Oracle SQL Trigger insert/update -
ok question should easy 1 think. learning triggers, , trying figure out homework question. have 3 tables, movies (title, year, length, genre, studioname, producer) starsin (movietitle, starname) moviestar (name, address, gender, birthdate)
so need write trigger assuring @ times, star appearing in starsin appears in moviestar. need make trigger both insert , update events.
update: ok changed statement little still can't figure out
create or replace trigger movietrigger after update or insert on starsin each row when(new.starname not in(select "name" moviestar)) begin insert moviestar("name") values(new.starname) end;
now getting error
error report: ora-02251: subquery not allowed here 02251. 00000 - "subquery not allowed here" *cause: subquery not allowed here in statement. *action: remove subquery statement.
i learned oracle not support subquery in when clause... trying figure out limited knowledge. if has clever way of doing know :-).
thanks again
you created statement-level trigger. fire once each insert or update statement. single insert or update statement can insert/update many rows in 1 go. code needs single row , assumes single row inserted or updated.
what need rowlevel triggers ("for each row") if want follow path.
Comments
Post a Comment