Maybe you can reformulate the query to fit

INSERT OR UPDATE INTO t SELECT t.a,t.b,...,s.x,s.y FROM t, s ...

-----Ursprüngliche Nachricht-----
Von: Mark Lawrence [mailto:no...@null.net]
Gesendet: Montag, 15. September 2014 10:51
An: sqlite-users@sqlite.org
Betreff: [sqlite] SET (x,y) = (x1,y1)?

I occasionally have the need to update two columns based on complex sub 
queries, which are often very similar

    UPDATE
        t
    SET
        x = ( SELECT 1...),
        y = ( SELECT 2...)    -- nearly the same as SELECT 1
    ;

Normally one could use a CTE to do the work once:

    WITH
        cte
    AS (
        SELECT 1 AS x, 2 AS y
    )
    UPDATE
        t
    SET
        x = cte.x,
        y = cte.y
    ;

However CTEs don't work within triggers.

I was wondering hard it would be to support the SET syntax as shown in the 
subject line. I believe something like that works in PostgreSQL and I could use 
it in SQLite for performance reasons.

    UPDATE
        t
    SET
        (x,y) = (SELECT 1,2)
    ;

Alternatively, is there any effort underway to make CTEs work inside triggers?

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


___________________________________________
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: h...@scigames.at

This communication (including any attachments) is intended for the use of the 
intended recipient(s) only and may contain information that is confidential, 
privileged or legally protected. Any unauthorized use or dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please immediately notify the sender by return e-mail message and 
delete all copies of the original communication. Thank you for your cooperation.


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

Reply via email to