title: Db2 merge from jdbc with dynamic values
body: <p>I would like to use the db2 merge statement submitting it as a statement from jdbc.
  I am in the following scenario. I'm working with a proprietary persistence layer and I'm handling an entity I don't know whether it's already persisted or not and I would like to use the merge statement in order to insert or update a row on the database.
  Is it possible?
  Suppose I'm working with the table <em>people</em> with three columns: <em>id, name, surname</em> and I'm handling an entity with id="5", name="chuck", surname="norris" Am I able to issue:</p>
  
  <pre><code>MERGE INTO people AS t
    USING (select '5' as id, 'chuck' as name, 'norris' as surname from SYSIBM.SYSDUMMY1)As s
      ON (t.id = s.id)
    WHEN MATCHED THEN 
        UPDATE SET t.name=s.name, t.surmane=s.surname
    WHEN NOT MATCHED THEN
      INSERT
        (id, name, surname)
      VALUES (s.id, s.name, s.surname)
  </code></pre>
  
  <p>such a statement? I'm trying to do that but I got an error. I don't think it's allowed to use a select after <em>USING</em>:</p>
  
  <pre><code>USING (select '5' as id, 'chuck' as name, 'norris' as surname from SYSIBM.SYSDUMMY1)As s
  </code></pre>
  
  <p>I also tryed to do:</p>
  
  <pre><code>USING VALUES('5','chuck','norris') AS s(id,chuck,norris)
  </code></pre>
  
  <p>but it dosn't work. Any help would be appreciated. 
  Besides, does anybody know if it's possible to use such a statement in a prepared statement, replacing the real values expressed into the USING part with '?' placeholders in order to set them to the prepared statement using the setXXX() methods? </p>
  
  <p>Thanks</p>
  
  <p>Thanks
  Fil</p>