title: Using a select statement in the bindValue(...) function - Qt & SQLite
body: <p>Imagine I have the following SQLite table definition:</p>
  
  <pre><code>create table test (id integer primary key, info integer);
  </code></pre>
  
  <p>and the following entries:</p>
  
  <pre><code>id  | info
  ----------
  1   | 10
  2   | 20
  3   | 30
  </code></pre>
  
  <p>I want to use Qt's <code>QSqlQuery</code> class in order to <code>prepare()</code> a query and use the <code>bindValue()</code> function.</p>
  
  <p>What I'm trying to achieve is something along the lines of </p>
  
  <pre><code>insert into test values (
      ( select id from test where ROWID = last_insert_rowid() )+100,
      666
  );
  </code></pre>
  
  <p>in order to get:</p>
  
  <pre><code>id  | info
  ----------
  1   | 10
  2   | 20
  3   | 30
  103 | 666
  </code></pre>
  
  <p>While that works directly <code>exec()</code>ing the statement via a <code>QSqlQuery qry</code> object, this</p>
  
  <pre><code>//qry is set up correctly.
  qry.prepare("insert into test values (?,?);");
  qry.bindValue(0, "select id from test where ROWID = last_insert_rowid() )+100");
  qry.bindValue(1,666);
  qry.exec();
  </code></pre>
  
  <p>doesn't work (datatype mismatch).</p>
  
  <p>1) How can I get this to work by using <code>bindValue()</code>?</p>
  
  <p>2) What is the neatest way to achieve the same behavior withouth using <code>last_insert_rowid()</code>?</p>
  
  <p>3) What would value would be returned by the code above for <code>id</code> if the table had no rows so far? Zero?</p>