I have a table of bids and everytime a bid is added in an auction I want to create new notifications to every bidder in that auction. As this is for a class of databases I though of doing a trigger to show some skills in oracle pl/sql. My trigger is like this:
CREATE OR REPLACE TRIGGER create_notifs
AFTER INSERT ON bid
FOR EACH ROW
BEGIN
INSERT INTO notification(id_notif, id_auction, username, time, seen_state)
SELECT notif_id_seq.NEXTVAL, :NEW.id_auction, username, SYSDATE, 0
FROM bid
WHERE bid.id_auction = :NEW.id_leilao;
END;
/
Now this trigger won't work because it's accessing the table that fired it. It is not a problem though because I'm not changing it and it really needs to be after the insertion because I need to see if it passes the constraints. How can I do this?