2

Is there a simple way of knowing whether an 'insert' or a 'replace' occured when doing an 'INSERT OR REPLACE' query in SQLite3?

2
  • You can check the ID of the row (in case you have such). When inserting it is empty and assigned from the SQLite engine, but for updating it should be full before the query runs. Unfortunately I have no so much details about how your DB is built or what you have at query time. Commented May 11, 2014 at 7:38
  • Thanks. If the database did have a row ID, what is the format of the query to check the row ID? Commented May 12, 2014 at 6:57

1 Answer 1

2

A yes/no answer would not suffice because it is possible to insert multiple records with one statement.

Functions such as sqlite3_changes do not count changes due to REPLACE constraints.

So this is not possible.

Sign up to request clarification or add additional context in comments.

1 Comment

I had looked at that page, and that was my conclusion, but not being experienced with SQLite I wanted to make sure. Thanks very much.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.