From 87528788f2a3b2b58e11eb6575f4cb2ca3baff8e Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Sat, 22 Sep 2018 01:01:44 -0400 Subject: [PATCH] fix --- db_deploy.sql | 15 +++------------ schema/triggers/bal_insert.sql | 15 +++------------ 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/db_deploy.sql b/db_deploy.sql index 6081d59..7c4abce 100644 --- a/db_deploy.sql +++ b/db_deploy.sql @@ -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 diff --git a/schema/triggers/bal_insert.sql b/schema/triggers/bal_insert.sql index a459543..1a90d12 100644 --- a/schema/triggers/bal_insert.sql +++ b/schema/triggers/bal_insert.sql @@ -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