189k views
1 vote
When inserting a new printer, check that the model number exists in product?

User Ozczecho
by
8.6k points

1 Answer

4 votes

We write this trigger in Oracle SQL in a following way;

CREATE TRIGGER NewPrinterTrigger

AFTER INSERT ON Printer

REFERENCING

NEW ROW AS NewRow,

NEW TABLE AS NewStuff

FOR EACH ROW

WHEN (NOT EXISTS (SELECT * FROM Product

WHERE Product.model = NewRow.model))

DELETE FROM Printer

WHERE (model, color, type, price) IN NewStuff;

User Lhan
by
8.3k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.

9.4m questions

12.2m answers

Categories