Reputation: 12416
In my Android application I am using compiled statements to be able to insert rows quickly:
insert = db.compileStatement(
"INSERT INTO foo (id, aaa, bbb, ccc) " +
"VALUES (?,?,?,?)");
This works correctly and quite fast. However when there is already foo
with id
, I am receiving following exception:
column id is not unique (code 19)
What would be a correct way for overwriting existing row?
Upvotes: 0
Views: 197
Reputation: 152797
What would be a correct way for overwriting existing row?
Specify a conflict resolution strategy, such as
INSERT OR REPLACE INTO foo ...
If the insert would result in a conflict, the conflicting row(s) are first deleted and then the new row is inserted.
Upvotes: 5