fix
This commit is contained in:
parent
4869265ea3
commit
87528788f2
@ -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 minrange
|
||||||
,CASE WHEN lower(f.dur) < max(lower(bp.dur)) THEN max(lower(bp.dur)) ELSE lower(f.dur) END maxrange
|
,CASE WHEN lower(f.dur) < max(lower(bp.dur)) THEN max(lower(bp.dur)) ELSE lower(f.dur) END maxrange
|
||||||
FROM
|
FROM
|
||||||
(
|
ins
|
||||||
SELECT
|
|
||||||
*
|
|
||||||
FROM
|
|
||||||
evt.bal
|
|
||||||
WHERE
|
|
||||||
fspr = '2018.11'
|
|
||||||
) ins
|
|
||||||
INNER JOIN evt.fspr f ON
|
INNER JOIN evt.fspr f ON
|
||||||
f.id = ins.fspr
|
f.id = ins.fspr
|
||||||
LEFT OUTER JOIN evt.bal b ON
|
LEFT OUTER JOIN evt.bal b ON
|
||||||
b.acct = ins.acct
|
b.acct = ins.acct
|
||||||
LEFT OUTER JOIN evt.fspr bp ON
|
LEFT OUTER JOIN evt.fspr bp ON
|
||||||
bp.id = b.fspr
|
bp.id = b.fspr
|
||||||
WHERE
|
|
||||||
b.fspr <> '2018.11'
|
|
||||||
GROUP BY
|
GROUP BY
|
||||||
ins.acct
|
ins.acct
|
||||||
,ins.fspr
|
,ins.fspr
|
||||||
@ -303,10 +294,10 @@ CREATE OR REPLACE FUNCTION evt.bal_insert() RETURNS trigger
|
|||||||
SELECT * FROM rf
|
SELECT * FROM rf
|
||||||
)
|
)
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
evt.bal (Acct, fspr, obal, debits, credits, cbal)
|
evt.bal (acct, fspr, obal, debits, credits, cbal)
|
||||||
SELECT
|
SELECT
|
||||||
acct
|
acct
|
||||||
,fspr
|
,id
|
||||||
,obal
|
,obal
|
||||||
,debits
|
,debits
|
||||||
,credits
|
,credits
|
||||||
|
@ -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 minrange
|
||||||
,CASE WHEN lower(f.dur) < max(lower(bp.dur)) THEN max(lower(bp.dur)) ELSE lower(f.dur) END maxrange
|
,CASE WHEN lower(f.dur) < max(lower(bp.dur)) THEN max(lower(bp.dur)) ELSE lower(f.dur) END maxrange
|
||||||
FROM
|
FROM
|
||||||
(
|
ins
|
||||||
SELECT
|
|
||||||
*
|
|
||||||
FROM
|
|
||||||
evt.bal
|
|
||||||
WHERE
|
|
||||||
fspr = '2018.11'
|
|
||||||
) ins
|
|
||||||
INNER JOIN evt.fspr f ON
|
INNER JOIN evt.fspr f ON
|
||||||
f.id = ins.fspr
|
f.id = ins.fspr
|
||||||
LEFT OUTER JOIN evt.bal b ON
|
LEFT OUTER JOIN evt.bal b ON
|
||||||
b.acct = ins.acct
|
b.acct = ins.acct
|
||||||
LEFT OUTER JOIN evt.fspr bp ON
|
LEFT OUTER JOIN evt.fspr bp ON
|
||||||
bp.id = b.fspr
|
bp.id = b.fspr
|
||||||
WHERE
|
|
||||||
b.fspr <> '2018.11'
|
|
||||||
GROUP BY
|
GROUP BY
|
||||||
ins.acct
|
ins.acct
|
||||||
,ins.fspr
|
,ins.fspr
|
||||||
@ -83,10 +74,10 @@ CREATE OR REPLACE FUNCTION evt.bal_insert() RETURNS trigger
|
|||||||
SELECT * FROM rf
|
SELECT * FROM rf
|
||||||
)
|
)
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
evt.bal (Acct, fspr, obal, debits, credits, cbal)
|
evt.bal (acct, fspr, obal, debits, credits, cbal)
|
||||||
SELECT
|
SELECT
|
||||||
acct
|
acct
|
||||||
,fspr
|
,id
|
||||||
,obal
|
,obal
|
||||||
,debits
|
,debits
|
||||||
,credits
|
,credits
|
||||||
|
Loading…
Reference in New Issue
Block a user