On 8 Mar 2012, at 7:43pm, Marc L. Allen <mlal...@outsitenetworks.com> wrote:

>>> What happens if the intermediate delete breaks a foreign key
>>> constraint?  And does it happen if the insert restores the foreign key?
>> 
>> The constraint stops the DELETE, and the operation fails.  Just like
>> you were worried about.  So instead of doing
>> 
>> INSERT OR REPLACE ...
>> 
>> you do
>> 
>> INSERT OR IGNORE ...
>> UPDATE ...
> 
> But then I am back to the problem of large, ugly, and unwieldy UPDATE 
> statements for multiple columns and joins.

That's why you don't make a DBMS (SQL) do the job of a programming language.  
Use your programming language to to retrieve the values you need to make your 
calculations.  Then use your programming language to figure out the new values 
and execute the UPDATE commands needed to make the changes.

SQL is not a programming language.  Trying to use it like one leads to 
ridiculous contortions which take longer to run than doing it all in SQL would 
take.  There's nothing magically fast about SQL, it still has to do the same 
amount of work in the end.

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

Reply via email to