This commit is contained in:
Paul Trowbridge 2018-09-22 01:01:44 -04:00
parent 4869265ea3
commit 87528788f2
2 changed files with 6 additions and 24 deletions

View File

@ -250,22 +250,13 @@ CREATE OR REPLACE FUNCTION evt.bal_insert() RETURNS trigger
,CASE WHEN lower(f.dur) > max(lower(bp.dur)) THEN max(lower(bp.dur)) ELSE lower(f.dur) END minrange
,CASE WHEN lower(f.dur) < max(lower(bp.dur)) THEN max(lower(bp.dur)) ELSE lower(f.dur) END maxrange
FROM
(
SELECT
*
FROM
evt.bal
WHERE
fspr = '2018.11'
) ins
ins
INNER JOIN evt.fspr f ON
f.id = ins.fspr
LEFT OUTER JOIN evt.bal b ON
b.acct = ins.acct
LEFT OUTER JOIN evt.fspr bp ON
bp.id = b.fspr
WHERE
b.fspr <> '2018.11'
GROUP BY
ins.acct
,ins.fspr
@ -303,10 +294,10 @@ CREATE OR REPLACE FUNCTION evt.bal_insert() RETURNS trigger
SELECT * FROM rf
)
INSERT INTO
evt.bal (Acct, fspr, obal, debits, credits, cbal)
evt.bal (acct, fspr, obal, debits, credits, cbal)
SELECT
acct
,fspr
,id
,obal
,debits
,credits

View File

@ -30,22 +30,13 @@ CREATE OR REPLACE FUNCTION evt.bal_insert() RETURNS trigger
,CASE WHEN lower(f.dur) > max(lower(bp.dur)) THEN max(lower(bp.dur)) ELSE lower(f.dur) END minrange
,CASE WHEN lower(f.dur) < max(lower(bp.dur)) THEN max(lower(bp.dur)) ELSE lower(f.dur) END maxrange
FROM
(
SELECT
*
FROM
evt.bal
WHERE
fspr = '2018.11'
) ins
ins
INNER JOIN evt.fspr f ON
f.id = ins.fspr
LEFT OUTER JOIN evt.bal b ON
b.acct = ins.acct
LEFT OUTER JOIN evt.fspr bp ON
bp.id = b.fspr
WHERE
b.fspr <> '2018.11'
GROUP BY
ins.acct
,ins.fspr
@ -83,10 +74,10 @@ CREATE OR REPLACE FUNCTION evt.bal_insert() RETURNS trigger
SELECT * FROM rf
)
INSERT INTO
evt.bal (Acct, fspr, obal, debits, credits, cbal)
evt.bal (acct, fspr, obal, debits, credits, cbal)
SELECT
acct
,fspr
,id
,obal
,debits
,credits