As i told you before i am using this database inside an application which is
merging/combining one source database table to destination database table. 

So in that case i am not writing the actual insert query.and in that case
all columns are taken.

The trigger inside the database should handle that when there is a duplicate
primary key then it should auto increment this primary key and insert the
new record with it .





P Kishor-3 wrote:
> 
> On Mon, Mar 15, 2010 at 8:32 AM, dravid11 <ahmadrath...@gmail.com> wrote:
>>
>> Well the situation is that i am merging data of one table in data of
>> another
>> table using a program
>> so it is going to add all values by it self .I am not actually using
>> insert
>> query in that case to select values to add.
>>
>>
>> There is another scenario , what if inserting a data and i want to bypass
>> the primary key conflict and just update rest of the values.
>>
> 
> INSERT INTO t1 (not_a_pk1, not_a_pk2...)
> SELECT not_a_pk1, not_a_pk2... FROM t2;
> 
> 
> And, please don't use double quotes to quote your strings. Use single
> quotes instead.
> 
> 
>> again i am combing two tables together so it should take all columns .
>>
>>
>>
>> Tim Romano wrote:
>>>
>>> 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
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/On-conflicting-Primary-key-how-to-insert-record-and-increment-the-Key-tp27904087p27904288.html
>> Sent from the SQLite mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
> 
> 
> 
> -- 
> Puneet Kishor
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> 

-- 
View this message in context: 
http://old.nabble.com/On-conflicting-Primary-key-how-to-insert-record-and-increment-the-Key-tp27904087p27904948.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to