update for new columns
This commit is contained in:
parent
f96a540210
commit
9f1d191b9e
@ -81,7 +81,7 @@ COMMENT ON COLUMN evt.bal.debits IS 'total debits';
|
||||
COMMENT ON COLUMN evt.bal.credits IS 'total credits';
|
||||
COMMENT ON COLUMN evt.bal.cbal IS 'closing balance';
|
||||
|
||||
-----------------------------------------process bpr insert trigger -----------------------------------
|
||||
---------------------------handle new logged event----------------------------------------
|
||||
|
||||
CREATE OR REPLACE FUNCTION evt.log_insert() RETURNS trigger
|
||||
LANGUAGE plpgsql
|
||||
@ -89,7 +89,7 @@ CREATE OR REPLACE FUNCTION evt.log_insert() RETURNS trigger
|
||||
$func$
|
||||
BEGIN
|
||||
WITH
|
||||
------------------------------------full extraction-------------------------------------------
|
||||
--full extraction
|
||||
full_ex AS (
|
||||
SELECT
|
||||
ins.id
|
||||
@ -113,7 +113,7 @@ CREATE OR REPLACE FUNCTION evt.log_insert() RETURNS trigger
|
||||
LEFT JOIN LATERAL JSONB_ARRAY_ELEMENTS(ins.bpr#>ARRAY['gl','jpath',(a.rn - 1)::text]) WITH ORDINALITY p(i, rn) ON TRUE
|
||||
)
|
||||
--select * from full_ex
|
||||
--------------------------------re-ggregate extraction to gl line level----------------------
|
||||
--re-ggregate extraction to gl line level
|
||||
,ex_gl_line AS (
|
||||
SELECT
|
||||
id
|
||||
@ -142,15 +142,19 @@ CREATE OR REPLACE FUNCTION evt.log_insert() RETURNS trigger
|
||||
RETURNING *
|
||||
)
|
||||
INSERT INTO
|
||||
evt.gl (bprid,acct, amount,glline, bprkeys)
|
||||
evt.gl (bprid,acct, amount,tstmp , fspr, glline, bprkeys)
|
||||
SELECT
|
||||
id
|
||||
,account
|
||||
,amount
|
||||
,(bprkeys->>'date')::timestamptz
|
||||
,p.fspr
|
||||
,gl_rownum
|
||||
,bprkeys
|
||||
FROM
|
||||
ex_gl_line;
|
||||
ex_gl_line
|
||||
LEFT OUTER JOIN evt.fspr p ON
|
||||
p.dur @> (bprkeys->>'date')::timestamptz;
|
||||
RETURN NULL;
|
||||
END;
|
||||
$func$;
|
||||
@ -162,5 +166,4 @@ CREATE TRIGGER log_insert
|
||||
FOR EACH STATEMENT
|
||||
EXECUTE PROCEDURE evt.log_insert();
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
@ -1,3 +1,4 @@
|
||||
---------------------------handle new logged event----------------------------------------
|
||||
|
||||
CREATE OR REPLACE FUNCTION evt.log_insert() RETURNS trigger
|
||||
LANGUAGE plpgsql
|
||||
@ -5,7 +6,7 @@ CREATE OR REPLACE FUNCTION evt.log_insert() RETURNS trigger
|
||||
$func$
|
||||
BEGIN
|
||||
WITH
|
||||
------------------------------------full extraction-------------------------------------------
|
||||
--full extraction
|
||||
full_ex AS (
|
||||
SELECT
|
||||
ins.id
|
||||
@ -29,7 +30,7 @@ CREATE OR REPLACE FUNCTION evt.log_insert() RETURNS trigger
|
||||
LEFT JOIN LATERAL JSONB_ARRAY_ELEMENTS(ins.bpr#>ARRAY['gl','jpath',(a.rn - 1)::text]) WITH ORDINALITY p(i, rn) ON TRUE
|
||||
)
|
||||
--select * from full_ex
|
||||
--------------------------------re-ggregate extraction to gl line level----------------------
|
||||
--re-ggregate extraction to gl line level
|
||||
,ex_gl_line AS (
|
||||
SELECT
|
||||
id
|
||||
@ -58,18 +59,22 @@ CREATE OR REPLACE FUNCTION evt.log_insert() RETURNS trigger
|
||||
RETURNING *
|
||||
)
|
||||
INSERT INTO
|
||||
evt.gl (bprid,acct, amount,glline, bprkeys)
|
||||
evt.gl (bprid,acct, amount,tstmp , fspr, glline, bprkeys)
|
||||
SELECT
|
||||
id
|
||||
,account
|
||||
,amount
|
||||
,gl_rownum
|
||||
,bprkeys
|
||||
e.id
|
||||
,e.account
|
||||
,e.amount
|
||||
,(e.bprkeys->>'date')::timestamptz
|
||||
,p.id
|
||||
,e.gl_rownum
|
||||
,e.bprkeys
|
||||
FROM
|
||||
ex_gl_line;
|
||||
ex_gl_line e
|
||||
LEFT OUTER JOIN evt.fspr p ON
|
||||
p.dur @> (bprkeys->>'date')::timestamptz;
|
||||
RETURN NULL;
|
||||
END;
|
||||
$func$
|
||||
$func$;
|
||||
|
||||
|
||||
CREATE TRIGGER log_insert
|
||||
|
Loading…
Reference in New Issue
Block a user