9

I am trying the INSERT OR REPLACE syntax in SQLite with no success so far because no rows are inserted.

My Create table query is

 create table providers (provider_id text not null, provider_name text not null, provider_channel_id text not null, channel_name text not null);CREATE UNIQUE INDEX channel_id ON providers (provider_channel_id); 

My INSERT OR Replace query is

INSERT OR REPLACE INTO providers (provider_channel_id, channel_name, provider_id, provider_name) VALUES ('1', '2', '3', '4') 

Thanks

2
  • Why you create provider_id column but insert into provider_channel_id column? Commented Sep 1, 2012 at 4:49
  • provider_channel_id is the column on which conflict should be detected, in query columns are quite out of order :) Commented Sep 1, 2012 at 5:05

1 Answer 1

5

the solution that i found .replace instead of insert you should also have a row id in the table and set it as PRIMARY KEY

 bdd.replace(table,null, contentValues); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.