update fspr to show roll was done

This commit is contained in:
Paul Trowbridge 2018-09-25 13:47:37 -04:00
parent 2374b060bd
commit 5ce69011c4

View File

@ -84,21 +84,38 @@ BEGIN
) )
select * from rf select * from rf
) )
INSERT INTO ,ins AS (
evt.bal INSERT INTO
SELECT evt.bal
acct SELECT
,id acct
,obal ,id
,debits ,obal
,credits ,debits
,cbal ,credits
,cbal
FROM
bld
ON CONFLICT ON CONSTRAINT bal_pk DO UPDATE SET
obal = EXCLUDED.obal
,debits = EXCLUDED.debits
,credits = EXCLUDED.credits
,cbal = EXCLUDED.cbal
RETURNING *
)
,touched AS (
SELECT DISTINCT
fspr
FROM
ins
)
UPDATE
evt.fspr f
SET
prop = f.prop || '{"rf":"global"}'::jsonb
FROM FROM
bld touched t
ON CONFLICT ON CONSTRAINT bal_pk DO UPDATE SET WHERE
obal = EXCLUDED.obal t.fspr = f.id;
,debits = EXCLUDED.debits
,credits = EXCLUDED.credits
,cbal = EXCLUDED.cbal;
END; END;
$func$; $func$;