title: How do I convert a character to integer within a PostgreSQL (9.1) function?
body: <p>I have this following code:</p>
  
  <pre><code>BEGIN
     x := split_part(text, ',', 1);
     UPDATE albumphoto SET order = 1 WHERE idtable = 1 AND idx = x;   
  END
  </code></pre>
  
  <p>But my column table named <code>idx</code> is a numeric type, and the <code>split_part</code> returns a character type to the variable <code>x</code>. I've tried using <code>CAST</code>, but I don't know how to use it properly.</p>
  
  <p>Any ideas?</p>