title: SQLITE - INSERT or UPDATE without changing ROWID value
body: <p>I need to update a table row IF EXISTS, otherwise INSERT a new row.
  I tried:</p>
  
  <pre><code>INSERT OR REPLACE INTO table VALUES ...
  </code></pre>
  
  <p>but if the row row exist this statement changes the row's ROWID, and that's what I'm trying to avoid (I need the rowid :D)</p>
  
  <p>I also tried to find a way to get some sort of return value from the update, in the case where an update has taken place, but I still don't understand how... If I could get the return value from the update statement, I could choose wether to proceed with an insert or not.</p>
  
  <p>Do you have any suggestion or solution to this problem? Or do I need to make a copy of the ROWID and use that instead of the "pure" table ROWID?</p>
  
  <p>Thanks in advance, best regards</p>
  
  <p>ps: I was looking <a href="https://stackoverflow.com/questions/700786/sql-update-a-row-and-returning-a-column-value-with-1-query">HERE</a> and I was wondering if sqlite has the OUTPUT special word too, but google didn't help me..</p>
  
  <p>---- EDIT after reading comments:</p>
  
  <p>table schema example</p>
  
  <pre><code>CREATE TABLE test (
      table_id TEXT NOT NULL,
      some_field TEXT NOT NULL,
      PRIMARY KEY(table_id)
  )
  
  INSERT or REPLACE INTO test (table_id, some_field) VALUES ("foo","bar")
  </code></pre>