If all you want to do is to insert a new row, do not mention the primary key column name in the insert statement:
INSERT INTO temp (address, weight) values( "blah blah", 100) The autoincrementing primary key will be autoincremented. Regards Tim Romano On 3/15/2010 9:15 AM, dravid11 wrote: > Hello ! > I have been trying to search for this solutions for days,yet did not find > the solution. > > > I want to write an insert query on a table. When there is a conflicting > primary key > then it should increment the primary key and insert the row . > > For example i want to run this query > INSERT INTO temp VALUES("1","112","112"); > > Here first column is auto increment primary Key. > This query will add the record(20,112,112) in the table > Now when i run the query as > > INSERT INTO temp VALUES("1","100","100"); > > I want the result as (2,100,100) > > But it give unique constraint error. > How can i do that ,i.e, duplicate primary key comes in a table insert the > new record and change the primary key of the new record. > > I have used this query but did not work > > insert or replace INTO temp (tempID,Address,Weight) > VALUES(new."tempID",new."Address",new."Weight") ; > SELECT RAISE(IGNORE); > END > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users