On Mon, Mar 12, 2012 at 9:02 AM, Christian Smith
<csm...@thewrongchristian.org.uk> wrote:
> On Fri, Mar 09, 2012 at 09:49:22AM +1100, BareFeetWare wrote:
>> I suggest only using "insert or replace" if you genuinely want to delete and 
>> replace with a new row. This is generally not hat you want if there are any 
>> foreign keys.
>>
>> Only use "insert or ignore" if you are inserting exactly the same row as 
>> what might already be there.
>>
>> Otherwise use a combination of insert and update.
>>
>> So, for example, if you are wanting to add a person that may not already be 
>> in your table:
>>
>> insert or ignore into "Person" ("First Name", "Last Name", "Company", 
>> "Email")
>> select 'Tom', 'Brodhurst-Hill', 'BareFeetWare', 'develo...@barefeetware.com')
>> ;
>> update "Person"
>> set "Email" = 'develo...@barefeetware.com'
>> where "First Name" = 'Tom' and "Last Name" = 'Brodhurst-Hill'
>> ;
>
> I've had a similar problem in the past, and solved it by using a pre-insert
> trigger to do the desired update.

Ah, yes, thanks!

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

Reply via email to