merge pt
This commit is contained in:
		
						commit
						4f958485d5
					
				| @ -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\dc.csv'' WITH (HEADER TRUE,DELIMITER '','', FORMAT CSV, ENCODING ''SQL_ASCII'',QUOTE ''"'');',_c); | ||||
|     _t := format('COPY csv_i (%s) FROM ''C:\Users\fleet\downloads\dfs.csv'' WITH (HEADER TRUE,DELIMITER '','', FORMAT CSV, ENCODING ''SQL_ASCII'',QUOTE ''"'');',_c); | ||||
| 
 | ||||
|     --RAISE NOTICE '%', _t; | ||||
| 
 | ||||
| @ -55,7 +55,7 @@ WITH pending_list AS ( | ||||
|                 (ae.e::text[])[1],                                  --the key name | ||||
|                 (row_to_json(i)::jsonb) #> ae.e::text[]             --get the target value from the key from the csv row that has been converted to json | ||||
|         ) json_key, | ||||
|         row_to_json(i)::JSONB rec, | ||||
|         row_to_json(i)::JSONB - 'id' rec, | ||||
|         srce, | ||||
|         --ae.rn, | ||||
|         id | ||||
| @ -87,7 +87,6 @@ WITH pending_list AS ( | ||||
|             t IS NULL | ||||
|     ----this conflict is only if an exact duplicate rec json happens, which will be rejected | ||||
|     ----therefore, records may not be inserted due to ay matches with certain json fields, or if the entire json is a duplicate, reason is not specified | ||||
|     ON CONFLICT ON CONSTRAINT uc_rec DO NOTHING | ||||
|     RETURNING * | ||||
| ) | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										11
									
								
								ubm_data.sql
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								ubm_data.sql
									
									
									
									
									
								
							| @ -2,8 +2,8 @@ | ||||
| -- PostgreSQL database dump | ||||
| -- | ||||
| 
 | ||||
| -- Dumped from database version 10rc1 | ||||
| -- Dumped by pg_dump version 10rc1 | ||||
| -- Dumped from database version 10beta4 | ||||
| -- Dumped by pg_dump version 10beta4 | ||||
| 
 | ||||
| SET statement_timeout = 0; | ||||
| SET lock_timeout = 0; | ||||
| @ -20,6 +20,7 @@ SET search_path = evt, pg_catalog; | ||||
| -- Data for Name: log; Type: TABLE DATA; Schema: evt; Owner: - | ||||
| -- | ||||
| 
 | ||||
| INSERT INTO log (id, rec) VALUES (1, '{"date": "2017-08-20", "item": [{"item": "Green Chili", "amount": 1.49, "account": "food"}, {"item": "Black Beans", "amount": 1.6, "account": "food"}, {"item": "Distilled Water", "amount": 7.12, "account": "food"}, {"item": "Fruit Preservative", "amount": 3.99, "account": "food"}, {"item": "Watch Battery", "amount": 3.79, "account": "stuff"}, {"item": "Sales Tax", "amount": "0.26", "account": "taxes"}, {"item": "Green Chili", "amount": -1.49, "account": "dcard"}, {"item": "Black Beans", "amount": -1.6, "account": "dcard"}, {"item": "Distilled Water", "amount": -7.12, "account": "dcard"}, {"item": "Fruit Preservative", "amount": -3.99, "account": "dcard"}, {"item": "Watch Battery", "amount": -3.79, "account": "dcard"}, {"item": "Sales Tax", "amount": -0.26, "account": "dcard"}], "vendor": "Drug Mart", "instrument": "Discover Card"}'); | ||||
| 
 | ||||
| 
 | ||||
| SET search_path = tps, pg_catalog; | ||||
| @ -28,8 +29,8 @@ SET search_path = tps, pg_catalog; | ||||
| -- Data for Name: srce; Type: TABLE DATA; Schema: tps; Owner: - | ||||
| -- | ||||
| 
 | ||||
| INSERT INTO srce (srce, defn) VALUES ('PNCC', '{"name": "PNCC", "type": "csv", "descr": "PNC Cash Accounts", "schema": [{"key": "AsOfDate", "type": "date"}, {"key": "BankId", "type": "text"}, {"key": "AccountNumber", "type": "text"}, {"key": "AccountName", "type": "text"}, {"key": "BaiControl", "type": "text"}, {"key": "Currency", "type": "text"}, {"key": "Transaction", "type": "text"}, {"key": "Reference", "type": "text"}, {"key": "Amount", "type": "text"}, {"key": "Description", "type": "text"}, {"key": "AdditionalRemittance", "type": "text"}], "unique_constraint": {"type": "range", "fields": ["{AsOfDate}"]}}'); | ||||
| INSERT INTO srce (srce, defn) VALUES ('PNCO', '{"name": "PNCO", "type": "csv", "descr": "PNC Loan Ledger", "schema": [{"key": "Loan#", "type": "text"}, {"key": "Post Date", "type": "date"}, {"key": "Effective Date", "type": "date"}, {"key": "Reference #", "type": "text"}, {"key": "Description", "type": "text"}, {"key": "Advances", "type": "numeric"}, {"key": "Adjustments", "type": "numeric"}, {"key": "Payments", "type": "numeric"}, {"key": "Loan Balance", "type": "numeric"}], "unique_constraint": {"type": "range", "fields": ["{Post Date}"]}}'); | ||||
| INSERT INTO srce (srce, defn) VALUES ('PNCC', '{"name": "PNCC", "type": "csv", "schema": [{"key": "AsOfDate", "type": "date"}, {"key": "BankId", "type": "text"}, {"key": "AccountNumber", "type": "text"}, {"key": "AccountName", "type": "text"}, {"key": "BaiControl", "type": "text"}, {"key": "Currency", "type": "text"}, {"key": "Transaction", "type": "text"}, {"key": "Reference", "type": "text"}, {"key": "Amount", "type": "text"}, {"key": "Description", "type": "text"}, {"key": "AdditionalRemittance", "type": "text"}], "unique_constraint": {"type": "range", "fields": ["{AsOfDate}"]}}'); | ||||
| INSERT INTO srce (srce, defn) VALUES ('DCARD', '{"name": "DCARD", "type": "csv", "schema": [{"key": "Trans. Date", "type": "date"}, {"key": "Post Date", "type": "date"}, {"key": "Description", "type": "text"}, {"key": "Amount", "type": "text"}, {"key": "Category", "type": "text"}], "unique_constraint": {"type": "key", "fields": ["{Post Date}", "{Trans. Date}"]}}'); | ||||
| 
 | ||||
| 
 | ||||
| -- | ||||
| @ -43,7 +44,7 @@ SET search_path = evt, pg_catalog; | ||||
| -- Name: log_id_seq; Type: SEQUENCE SET; Schema: evt; Owner: - | ||||
| -- | ||||
| 
 | ||||
| SELECT pg_catalog.setval('log_id_seq', 1, false); | ||||
| SELECT pg_catalog.setval('log_id_seq', 1, true); | ||||
| 
 | ||||
| 
 | ||||
| SET search_path = tps, pg_catalog; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user