title: SQLSTATE[22P02]: Invalid text representation
body: <p>I'm using <strong>Postgresql</strong> and <strong>PHP 5.3.x with PDO</strong> to access the DB.</p>
  
  <p>I have this the SQL query (stripped down version), with a placeholder for PDO to fill in:</p>
  
  <pre><code>INSERT INTO t_articles (a_article_id) VALUES (?) RETURNING a_id
  </code></pre>
  
  <p>I want <code>a_article_id</code> to be either a number, like <code>5</code>, or else it should be the result of the subquery:</p>
  
  <pre><code>((SELECT max(a_article_id) FROM t_articles) + 1)
  </code></pre>
  
  <p>However, PDO says:</p>
  
  <pre><code>SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "(SELECT max(a_article_id) FROM t_articles) + 1"
  </code></pre>
  
  <p>And I've tried to set the subquery as the default value, but it is not allowed apparently:</p>
  
  <pre><code>ERROR:  cannot use sub query in default expression
  </code></pre>
  
  <p>How can I insert the result of this sub query (or what can be done to achieve the same result)?</p>