title: Triggers on Views in PostgreSQL
body: <p>I want to create a trigger for my view in PostgreSQL. The idea is that all new data must fulfill a condition to be inserted. But something is wrong here and I can't find the answer in manuals.</p>
  
  <pre><code>CREATE OR REPLACE VIEW My_View AS 
  SELECT name, adress, count FROM club, band, country;
  
  CREATE OR REPLACE FUNCTION insert() RETURNS TRIGGER AS $$
  BEGIN
      IF(NEW.count &gt; 10) THEN
      INSERT INTO My_View VALUES (NEW.name, NEW.adress, NEW.count);
      END IF;
  END;
  $$ LANGUAGE plpgsql;
  
  CREATE TRIGGER insert INSTEAD OF INSERT ON My_View
  FOR EACH ROW EXECUTE PROCEDURE insert();
  </code></pre>