several type conversion required

This commit is contained in:
Paul Trowbridge 2018-09-20 23:38:11 -04:00
parent de2fdc869f
commit bd26f4ab2f
3 changed files with 13 additions and 15 deletions

View File

@ -68,7 +68,7 @@ COMMENT ON COLUMN evt.gl.bprkeys IS 'extract from initial basic pecuniary record
CREATE TABLE evt.bal ( CREATE TABLE evt.bal (
acct ltree REFERENCES evt.acct(acct) acct ltree REFERENCES evt.acct(acct)
,perd ltree ,perd ltree REFERENCES evt.fspr(id)
,obal numeric(12,2) ,obal numeric(12,2)
,debits numeric(12,2) ,debits numeric(12,2)
,credits numeric(12,2) ,credits numeric(12,2)
@ -117,7 +117,7 @@ CREATE OR REPLACE FUNCTION evt.log_insert() RETURNS trigger
,ex_gl_line AS ( ,ex_gl_line AS (
SELECT SELECT
id id
,gl_line->>'account' account ,(gl_line->>'account')::ltree account
,(gl_line->>'amount')::numeric amount ,(gl_line->>'amount')::numeric amount
,gl_rownum ,gl_rownum
--aggregate all the path references back to the gl line --aggregate all the path references back to the gl line
@ -144,15 +144,15 @@ CREATE OR REPLACE FUNCTION evt.log_insert() RETURNS trigger
INSERT INTO INSERT INTO
evt.gl (bprid,acct, amount,tstmp , fspr, glline, bprkeys) evt.gl (bprid,acct, amount,tstmp , fspr, glline, bprkeys)
SELECT SELECT
id e.id
,account ,e.account
,amount ,e.amount
,(bprkeys->>'date')::timestamptz ,(e.bprkeys->>'date')::timestamptz
,p.fspr ,p.id
,gl_rownum ,e.gl_rownum
,bprkeys ,e.bprkeys
FROM FROM
ex_gl_line ex_gl_line e
LEFT OUTER JOIN evt.fspr p ON LEFT OUTER JOIN evt.fspr p ON
p.dur @> (bprkeys->>'date')::timestamptz; p.dur @> (bprkeys->>'date')::timestamptz;
RETURN NULL; RETURN NULL;
@ -164,6 +164,4 @@ CREATE TRIGGER log_insert
AFTER INSERT ON evt.bpr AFTER INSERT ON evt.bpr
REFERENCING NEW TABLE AS ins REFERENCING NEW TABLE AS ins
FOR EACH STATEMENT FOR EACH STATEMENT
EXECUTE PROCEDURE evt.log_insert(); EXECUTE PROCEDURE evt.log_insert();
COMMIT;

View File

@ -2,7 +2,7 @@
CREATE TABLE evt.bal ( CREATE TABLE evt.bal (
acct ltree REFERENCES evt.acct(acct) acct ltree REFERENCES evt.acct(acct)
,perd ltree ,perd ltree REFERENCES evt.fspr(id)
,obal numeric(12,2) ,obal numeric(12,2)
,debits numeric(12,2) ,debits numeric(12,2)
,credits numeric(12,2) ,credits numeric(12,2)

View File

@ -34,7 +34,7 @@ CREATE OR REPLACE FUNCTION evt.log_insert() RETURNS trigger
,ex_gl_line AS ( ,ex_gl_line AS (
SELECT SELECT
id id
,gl_line->>'account' account ,(gl_line->>'account')::ltree account
,(gl_line->>'amount')::numeric amount ,(gl_line->>'amount')::numeric amount
,gl_rownum ,gl_rownum
--aggregate all the path references back to the gl line --aggregate all the path references back to the gl line