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

Reply via email to