diff --git a/srce.pgsql b/srce.pgsql index 98b4a21..8cd7421 100644 --- a/srce.pgsql +++ b/srce.pgsql @@ -18,7 +18,7 @@ BEGIN --unwrap the schema definition array LEFT JOIN LATERAL jsonb_populate_recordset(null::tps.srce_defn_schema, defn->'schema') prs ON TRUE WHERE - srce = 'DCARD' + srce = 'HUNT' GROUP BY srce; @@ -35,7 +35,7 @@ BEGIN ----------------------------------------------------do the insert------------------------------------------------------------------------------------------- --the column list needs to be dynamic forcing this whole line to be dynamic - _t := format('COPY csv_i (%s) FROM ''C:\Users\fleet\downloads\dfs.csv'' WITH (HEADER TRUE,DELIMITER '','', FORMAT CSV, ENCODING ''SQL_ASCII'',QUOTE ''"'');',_c); + _t := format('COPY csv_i (%s) FROM ''C:\Users\fleet\downloads\hunt.csv'' WITH (HEADER TRUE,DELIMITER '','', FORMAT CSV, ENCODING ''SQL_ASCII'',QUOTE ''"'');',_c); --RAISE NOTICE '%', _t; @@ -62,7 +62,7 @@ WITH pending_list AS ( FROM csv_i i INNER JOIN tps.srce s ON - s.srce = 'DCARD' + s.srce = 'HUNT' LEFT JOIN LATERAL JSONB_ARRAY_ELEMENTS_TEXT(defn->'unique_constraint'->'fields') WITH ORDINALITY ae(e, rn) ON TRUE GROUP BY i.*, diff --git a/transaction_range.pgsql b/transaction_range.pgsql index b4f469e..c654915 100644 --- a/transaction_range.pgsql +++ b/transaction_range.pgsql @@ -11,4 +11,7 @@ FROM LEFT JOIN LATERAL JSONB_ARRAY_ELEMENTS_TEXT(defn->'unique_constraint'->'fields') WITH ORDINALITY ae(e, rn) ON TRUE GROUP BY t.srce - ,(ae.e::text[])[1] \ No newline at end of file + ,(ae.e::text[])[1] +ORDER BY + t.srce + ,(ae.e::text[])[1] diff --git a/ubm_data.sql b/ubm_data.sql index 38a0bc4..9254c16 100644 --- a/ubm_data.sql +++ b/ubm_data.sql @@ -543,6 +543,49 @@ INSERT INTO trans (id, srce, rec, map) VALUES (2593, 'HUNT', '{"Date": "2014-09- INSERT INTO trans (id, srce, rec, map) VALUES (2594, 'HUNT', '{"Date": "2014-09-03", "Memo": "SUBSTITUTE CHECK", "Amount": "-4550", "Payee Name": "", "Category Name": "", "Reference Number": 1602}', NULL); INSERT INTO trans (id, srce, rec, map) VALUES (2595, 'HUNT', '{"Date": "2014-08-28", "Memo": "DISCOVER E-PAYMENT 140827", "Amount": "-3073.4", "Payee Name": "DISCOVER E-PAYMENT", "Category Name": "", "Reference Number": 0}', NULL); INSERT INTO trans (id, srce, rec, map) VALUES (7, 'DCARD', '{"Amount": "28.00", "Category": "Restaurants", "Post Date": "2017-06-23", "Description": "CHIPOTLE 1152 STOW OH", "Trans. Date": "2017-06-23"}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2596, 'HUNT', '{"Date": "2017-10-17", "Memo": "DOM EAST OHIO ONLINE PMT171017", "Amount": "-38.81", "Payee Name": "DOM EAST OHIO ONLINE PMT", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2597, 'HUNT', '{"Date": "2017-10-17", "Memo": "PURCHASE NORWEX USA I", "Amount": "-10.66", "Payee Name": "NORWEX USA INC.", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2598, 'HUNT', '{"Date": "2017-10-13", "Memo": "HUNTINGTON ATM CASH WITHDRAWAL", "Amount": "-40", "Payee Name": "HUNTINGTON ATM CASH WITHDRAWAL", "Category Name": "", "Reference Number": 753}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2599, 'HUNT', '{"Date": "2017-10-13", "Memo": "THE HC COMPANIESDIRECT DEP171013", "Amount": "2612.37", "Payee Name": "THE HC COMPANIES DIRECT DEP", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2600, 'HUNT', '{"Date": "2017-10-11", "Memo": "FIRSTENERGY OPCOFE ECHECK", "Amount": "-108.25", "Payee Name": "FIRSTENERGY OPCO FE ECHECK", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2601, 'HUNT', '{"Date": "2017-10-11", "Memo": "REPUBLICSERVICESRSIBILLPAY101117", "Amount": "-69", "Payee Name": "REPUBLICSERVICES RSIBILLPAY", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2602, 'HUNT', '{"Date": "2017-10-10", "Memo": "Lowes CC LWS EPAY 100917", "Amount": "-50.67", "Payee Name": "Lowes CC LWS EPAY", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2603, 'HUNT', '{"Date": "2017-10-04", "Memo": "SUBSTITUTE CHECK", "Amount": "-1650", "Payee Name": "", "Category Name": "", "Reference Number": 1840}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2604, 'HUNT', '{"Date": "2017-10-04", "Memo": "SUBSTITUTE CHECK", "Amount": "-610.01", "Payee Name": "", "Category Name": "", "Reference Number": 1838}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2605, 'HUNT', '{"Date": "2017-10-04", "Memo": "HARLAND CLARKE CHK ORDER 170930", "Amount": "-56.2", "Payee Name": "", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2606, 'HUNT', '{"Date": "2017-10-03", "Memo": "PURCHASE ERIE INSURAN", "Amount": "-523", "Payee Name": "ERIE INSURANCE", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2607, 'HUNT', '{"Date": "2017-10-02", "Memo": "DISCOVER E-PAYMENT 170930", "Amount": "-2216.82", "Payee Name": "DISCOVER E-PAYMENT", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2608, 'HUNT', '{"Date": "2017-10-02", "Memo": "PURCHASE NORWEX USA I", "Amount": "-73.79", "Payee Name": "NORWEX USA INC.", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2609, 'HUNT', '{"Date": "2017-10-02", "Memo": "PURCHASE NORWEX USA I", "Amount": "-201.9", "Payee Name": "NORWEX USA INC.", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2610, 'HUNT', '{"Date": "2017-09-29", "Memo": "THE HC COMPANIESDIRECT DEP170929", "Amount": "2612.37", "Payee Name": "THE HC COMPANIES DIRECT DEP", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2611, 'HUNT', '{"Date": "2017-09-25", "Memo": "SUBSTITUTE CHECK", "Amount": "-42.94", "Payee Name": "", "Category Name": "", "Reference Number": 1837}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2612, 'HUNT', '{"Date": "2017-09-20", "Memo": "PURCHASE ERIE INSURAN", "Amount": "-772", "Payee Name": "ERIE INSURANCE", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2613, 'HUNT', '{"Date": "2017-09-19", "Memo": "DOM EAST OHIO ONLINE PMT170919", "Amount": "-38.82", "Payee Name": "DOM EAST OHIO ONLINE PMT", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2614, 'HUNT', '{"Date": "2017-09-18", "Memo": "SUBSTITUTE CHECK", "Amount": "-1000", "Payee Name": "", "Category Name": "", "Reference Number": 1335}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2615, 'HUNT', '{"Date": "2017-09-18", "Memo": "DEPOSIT", "Amount": "10895.51", "Payee Name": "", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2616, 'HUNT', '{"Date": "2017-09-15", "Memo": "THE HC COMPANIESDIRECT DEP170915", "Amount": "2612.37", "Payee Name": "THE HC COMPANIES DIRECT DEP", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2617, 'HUNT', '{"Date": "2017-09-14", "Memo": "SUBSTITUTE CHECK", "Amount": "-700", "Payee Name": "", "Category Name": "", "Reference Number": 1836}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2618, 'HUNT', '{"Date": "2017-09-12", "Memo": "PURCHASE NORWEX USA I", "Amount": "-239.23", "Payee Name": "NORWEX USA INC.", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2619, 'HUNT', '{"Date": "2017-09-11", "Memo": "HUNTINGTON ATM CASH WITHDRAWAL", "Amount": "-80", "Payee Name": "HUNTINGTON ATM CASH WITHDRAWAL", "Category Name": "", "Reference Number": 3916}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2620, 'HUNT', '{"Date": "2017-09-08", "Memo": "SUBSTITUTE CHECK", "Amount": "-50", "Payee Name": "", "Category Name": "", "Reference Number": 1825}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2621, 'HUNT', '{"Date": "2017-09-07", "Memo": "FIRSTENERGY OPCOFE ECHECK", "Amount": "-135.91", "Payee Name": "FIRSTENERGY OPCO FE ECHECK", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2622, 'HUNT', '{"Date": "2017-09-06", "Memo": "KOHL''S DEPT STRSCHG PYMT 170905", "Amount": "-222.85", "Payee Name": "KOHL''S DEPT STRS CHG PYMT", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2623, 'HUNT', '{"Date": "2017-09-06", "Memo": "SUBSTITUTE CHECK", "Amount": "-610.01", "Payee Name": "", "Category Name": "", "Reference Number": 1834}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2624, 'HUNT', '{"Date": "2017-09-06", "Memo": "SUBSTITUTE CHECK", "Amount": "-50", "Payee Name": "", "Category Name": "", "Reference Number": 1832}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2625, 'HUNT', '{"Date": "2017-09-05", "Memo": "DISCOVER E-PAYMENT 170901", "Amount": "-1943.85", "Payee Name": "DISCOVER E-PAYMENT", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2626, 'HUNT', '{"Date": "2017-09-01", "Memo": "SUBSTITUTE CHECK/WITHDRAWAL", "Amount": "-100", "Payee Name": "", "Category Name": "", "Reference Number": 1833}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2627, 'HUNT', '{"Date": "2017-09-01", "Memo": "PURCHASE NORWEX USA I", "Amount": "-10.66", "Payee Name": "NORWEX USA INC.", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2628, 'HUNT', '{"Date": "2017-09-01", "Memo": "PURCHASE SEARS LANDIN", "Amount": "-83.39", "Payee Name": "SEARS LANDING GRILL AN", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2629, 'HUNT', '{"Date": "2017-09-01", "Memo": "THE HC COMPANIESDIRECT DEP170901", "Amount": "2612.36", "Payee Name": "THE HC COMPANIES DIRECT DEP", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2630, 'HUNT', '{"Date": "2017-08-23", "Memo": "SUBSTITUTE CHECK", "Amount": "-1700", "Payee Name": "", "Category Name": "", "Reference Number": 1830}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2631, 'HUNT', '{"Date": "2017-08-21", "Memo": "SUBSTITUTE CHECK", "Amount": "-75", "Payee Name": "", "Category Name": "", "Reference Number": 1827}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2632, 'HUNT', '{"Date": "2017-08-21", "Memo": "SUBSTITUTE CHECK", "Amount": "-79.28", "Payee Name": "", "Category Name": "", "Reference Number": 131}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2633, 'HUNT', '{"Date": "2017-08-18", "Memo": "DOM EAST OHIO ONLINE PMT170818", "Amount": "-39.5", "Payee Name": "DOM EAST OHIO ONLINE PMT", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2634, 'HUNT', '{"Date": "2017-08-18", "Memo": "SUBSTITUTE CHECK/WITHDRAWAL", "Amount": "-57.4", "Payee Name": "", "Category Name": "", "Reference Number": 1829}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2635, 'HUNT', '{"Date": "2017-08-18", "Memo": "THE HC COMPANIESDIRECT DEP170818", "Amount": "2612.38", "Payee Name": "THE HC COMPANIES DIRECT DEP", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2636, 'HUNT', '{"Date": "2017-08-10", "Memo": "Lowes CC LWS EPAY 080917", "Amount": "-386.08", "Payee Name": "Lowes CC LWS EPAY", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2637, 'HUNT', '{"Date": "2017-08-10", "Memo": "FIRSTENERGY OPCOFE ECHECK", "Amount": "-167.81", "Payee Name": "FIRSTENERGY OPCO FE ECHECK", "Category Name": "", "Reference Number": 0}', NULL); +INSERT INTO trans (id, srce, rec, map) VALUES (2638, 'HUNT', '{"Date": "2017-08-09", "Memo": "SUBSTITUTE CHECK", "Amount": "-700", "Payee Name": "", "Category Name": "", "Reference Number": 1828}', NULL); INSERT INTO trans (id, srce, rec, map) VALUES (8, 'DCARD', '{"Amount": "22.40", "Category": "Supermarkets", "Post Date": "2017-06-23", "Description": "ACME NO. 17 STOW OH", "Trans. Date": "2017-06-23"}', NULL); INSERT INTO trans (id, srce, rec, map) VALUES (1304, 'DCARD', '{"Amount": "26.83", "Category": "Restaurants", "Post Date": "2015-10-22", "Description": "3 PALMS HUDSON OH", "Trans. Date": "2015-10-22"}', NULL); INSERT INTO trans (id, srce, rec, map) VALUES (9, 'DCARD', '{"Amount": "19.45", "Category": "Supermarkets", "Post Date": "2017-06-23", "Description": "ACME NO. 17 STOW OH", "Trans. Date": "2017-06-23"}', NULL); @@ -2649,7 +2692,7 @@ SET search_path = tps, pg_catalog; -- Name: trans_id_seq; Type: SEQUENCE SET; Schema: tps; Owner: - -- -SELECT pg_catalog.setval('trans_id_seq', 2595, true); +SELECT pg_catalog.setval('trans_id_seq', 2638, true); -- diff --git a/ubm_schema.sql b/ubm_schema.sql index 964a317..2028c58 100644 --- a/ubm_schema.sql +++ b/ubm_schema.sql @@ -58,6 +58,33 @@ COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; SET search_path = tps, pg_catalog; +-- +-- Name: dcard; Type: TYPE; Schema: tps; Owner: - +-- + +CREATE TYPE dcard AS ( + "Trans. Date" date, + "Post Date" date, + "Description" text, + "Amount" text, + "Category" text +); + + +-- +-- Name: hunt; Type: TYPE; Schema: tps; Owner: - +-- + +CREATE TYPE hunt AS ( + "Date" date, + "Reference Number" numeric, + "Payee Name" text, + "Memo" text, + "Amount" text, + "Category Name" text +); + + -- -- Name: srce_defn_schema; Type: TYPE; Schema: tps; Owner: - --