Kees Nuyt, out of the goodness of his heart, wrote:

> On Wed, 21 Jul 2010 14:28:12 -0400, "jose isaias cabrera"
>  wrote:
>
>>
>>Greetings and salutations.
>>
>>I believe this is possible, but I can not seem to get the syntax from the
>>site.  I have these 3 commands and 3 different steps that I want to put 
>>into
>>one:
>>
>>1. result1 = SELECT sum(price) FROM table1 WHERE subProjID = 24;
>>2. result2 = SELECT sum(price) FROM table2 WHERE ProjID = 8;
>>3. BEGIN;
>>      UPDATE LSOpenSubProjects SET price = result1 WHERE subProjID = 24;
>>      UPDATE LSOpenSubProjects SET udate = now WHERE subProjID = 24;
>>      UPDATE LSOpenProjects SET price = result2 WHERE ProjID = 8;
>>      UPDATE LSOpenProjects SET udate = now WHERE ProjID = 8;
>>    END;
>>
>>How can I put all of these 3 steps into one?
>
> BEGIN IMMEDIATE TRANSACTION;
> UPDATE LSOpenSubProjects
> SET
> price = (
> SELECT sum(price)
> FROM table1
> WHERE subProjID = 24
> ),
> udate = julianday('now')
> WHERE subProjID = 24;
> UPDATE LSOpenProjects
> SET
> price = (
> SELECT sum(price)
> FROM table2
> WHERE subProjID = 8
> ),
> udate = julianday('now')
> WHERE ProjID = 8;
> COMMIT TRANSACTION;
>
> (untested)

thanks.  This one is also nice.

josé 

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

Reply via email to