title: postgresql:ERROR: negative substring length not allowed
body: <p>I receive the error message ERROR: negative substring length not allowed when I run the following query in postgresql:</p>
  
  <pre><code>update main as m set filcase_type=subquery.filcase from
  (SELECT filcase_type ,
  Position('SR' in filcase_type) ,substring(filcase_type,1,position('SR' in filcase_type)-1)  as filcase
  FROM main) as subquery 
  WHERE right(m.filcase_type,2)='SR';
  </code></pre>
  
  <p>Any suggestions for what may have been over-looked? Thanks!</p>