I'm doing a triggers which do DML operations on view. There are two sample tables:
Vehicle: vehicle_id, size, brand_id
Brand: brand_id, name
I created a view:
CREATE OR REPLACE VIEW vehicle_view AS
SELECT vehicle_id, size, brand.name FROM Vehicle
JOIN Brand USING (brand_id)
How can I do UPDATE trigger? I successfully did trigger for INSERT, but I can't find way to create UPDATE trigger.
CREATE OR REPLACE TRIGGER tr_vehicle_update
INSTEAD OF INSERT OR UPDATE ON vehicle_view
BEGIN
UPDATE Vehicle SET
vehicle_id = :new.vehicle_id
WHERE size = :new.size;
UPDATE Brand SET
brand_id = :new.brand_id
WHERE name = :new.name;
END;