From 8f89cb98e774872f519f0b734d89a0f53d689acc Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Mon, 24 Sep 2018 09:29:41 -0400 Subject: [PATCH] add jsonb aggregate inside evt --- db_deploy.sql | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/db_deploy.sql b/db_deploy.sql index 3ed4968..97ad64d 100644 --- a/db_deploy.sql +++ b/db_deploy.sql @@ -128,7 +128,7 @@ CREATE OR REPLACE FUNCTION evt.log_insert() RETURNS trigger ,(gl_line->>'amount')::numeric amount ,gl_rownum --aggregate all the path references back to the gl line - ,public.jsonb_concat(bpr_extract) bprkeys + ,evt.jsonb_concat(bpr_extract) bprkeys FROM full_ex GROUP BY @@ -295,4 +295,29 @@ CREATE TRIGGER gl_insert FOR EACH STATEMENT EXECUTE PROCEDURE evt.gl_insert(); +------------------------json concetenate aggregate------------------------------------------- + +CREATE OR REPLACE FUNCTION evt.jsonb_concat( + state jsonb, + concat jsonb) + RETURNS jsonb + LANGUAGE 'plpgsql' +AS $BODY$ + +BEGIN + --RAISE notice 'state is %', state; + --RAISE notice 'concat is %', concat; + RETURN state || concat; +END; + +$BODY$; + +CREATE AGGREGATE evt.jsonb_concat(jsonb) ( + SFUNC=evt.jsonb_concat, + STYPE=jsonb, + INITCOND='{}' +); + + + COMMIT; \ No newline at end of file