title: Increment value of a column field whenever SELECT row
body: <p>So I have this function that works very nicely to update the count of views on a product:</p>
  <pre><code>UPDATE products SET view=view+1 WHERE id=@id RETURNING *
  </code></pre>
  <p>The problem is that I am currently switching my users to read-only to add more security. Unfortunately, as this function updates the number of view, it is not possible, since it is an update operation.</p>
  <p>So I was wondering if there is any way that PSQL would allow me to create a trigger function that update column value each time data is queried ? I looked at the <a href="https://www.postgresql.org/docs/9.1/sql-createtrigger.html" rel="nofollow noreferrer">official documentation</a> but did not notice any example related to my usecase.</p>
  <p>Perhaps something like this (pseudo-code):</p>
  <pre><code>CREATE TRIGGER view_increment
      AFTER SELECT ON products WHERE id=@id
      EXECUTE SET view=view+1;
  </code></pre>