title: How to raise an error with PostgreSQL select statement?
body: <p>I need to create a data patching script and I'd like to rollback the transaction when some condition occurs.</p>
  
  <p>I could do something like this in the end of the script:</p>
  
  <pre><code>select t.id / 0
  from some_table t
  where t.state = 'undersirable state'
  </code></pre>
  
  <p>but I'd rather have a more appropriate error message than "division by zero".</p>
  
  <p>Is there a generic function for generating errors in PostgreSQL? I'd like to do it without PL/SQL, if possible.</p>