Complete the code to create a view named 'employee_view' selecting all columns from 'employees'.
CREATE VIEW employee_view AS SELECT [1] FROM employees;The * selects all columns from the table.
Complete the code to create an INSTEAD OF trigger function named 'employee_view_insert' for the view.
CREATE FUNCTION employee_view_insert() RETURNS trigger AS $$ BEGIN INSERT INTO employees VALUES ([1]); RETURN NEW; END; $$ LANGUAGE plpgsql;NEW. prefix.The NEW keyword references the new row's columns in the trigger function.
Fix the error in the trigger creation by completing the code to attach the INSTEAD OF INSERT trigger to 'employee_view'.
CREATE TRIGGER employee_view_insert_trigger INSTEAD OF INSERT ON employee_view FOR EACH ROW EXECUTE FUNCTION [1]();The trigger must call the function employee_view_insert defined earlier.
Fill both blanks to complete the INSTEAD OF UPDATE trigger function that updates the 'employees' table when the view is updated.
CREATE FUNCTION employee_view_update() RETURNS trigger AS $$ BEGIN UPDATE employees SET [1] = NEW.[2], salary = NEW.salary, department = NEW.department WHERE id = OLD.id; RETURN NEW; END; $$ LANGUAGE plpgsql;
The name column is updated by setting it to NEW.name.
Fill all three blanks to complete the INSTEAD OF DELETE trigger function that deletes from 'employees' when a row is deleted from the view.
CREATE FUNCTION employee_view_delete() RETURNS trigger AS $$ BEGIN DELETE FROM employees WHERE [1] = OLD.[2]; RETURN [3]; END; $$ LANGUAGE plpgsql;
The delete matches on id column and returns OLD row after deletion.