add column to event_log. demonstact GL extraction and load initial row
This commit is contained in:
		
							parent
							
								
									2838ff4cc5
								
							
						
					
					
						commit
						7ad5b8dd6f
					
				
							
								
								
									
										
											BIN
										
									
								
								build_json.xlsx
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								build_json.xlsx
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -77,7 +77,8 @@ FROM | ||||
|         m.regex->>'function' = 'replace' | ||||
| WHERE | ||||
|     --t.srce = 'PNCC' | ||||
|     rec @> '{"Transaction":"ACH Credits","Transaction":"ACH Debits"}' | ||||
|     --rec @> '{"Transaction":"ACH Credits","Transaction":"ACH Debits"}' | ||||
|     t.map IS NULL | ||||
|     --rec @> '{"Description":"CHECK 93013270 086129935"}'::jsonb | ||||
| ORDER BY  | ||||
|     t.id DESC, | ||||
| @ -200,7 +201,7 @@ GROUP BY | ||||
| 
 | ||||
| SELECT srce, id, jsonb_pretty(retain_val), jsonb_pretty(map) FROM agg_to_id | ||||
| 
 | ||||
| /* | ||||
| 
 | ||||
| UPDATE | ||||
|     tps.trans t | ||||
| SET | ||||
| @ -211,4 +212,3 @@ FROM | ||||
|     agg_to_id o | ||||
| WHERE | ||||
|     o.id = t.id; | ||||
| */ | ||||
							
								
								
									
										22
									
								
								evt_log_gl_extract.pgsql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								evt_log_gl_extract.pgsql
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| 
 | ||||
| WITH j AS ( | ||||
| SELECT | ||||
|     id, | ||||
|     post_stmp, | ||||
|     rec as r | ||||
| FROM | ||||
|     evt.log | ||||
| ) | ||||
| 
 | ||||
| --this is a dynamic approach that dumps all keys into the json except several that are required which it extracts | ||||
| SELECT | ||||
|     id, | ||||
|     ARRAY['GL',rn::text] json_path, | ||||
|     post_stmp, | ||||
|     a.i->>'amt' amount, | ||||
|     a.i->>'account' account, | ||||
|     a.i->>'date' tran_date, | ||||
|     a.i - '{amt,account,date}'::text[] as therest | ||||
| FROM | ||||
|     j | ||||
|     LEFT JOIN LATERAL JSONB_ARRAY_ELEMENTS(j.r->'GL') WITH ORDINALITY a(i, rn) ON TRUE | ||||
| @ -150,7 +150,7 @@ FROM | ||||
|     $j$::jsonb | ||||
|     , 2) | ||||
| ) x; | ||||
| */ | ||||
| 
 | ||||
| DELETE FROM tps.map_rm  where target = 'Parse ACH'; | ||||
| 
 | ||||
| INSERT INTO | ||||
| @ -249,3 +249,31 @@ FROM | ||||
|     $j$::jsonb | ||||
|     , 2) | ||||
| ) x; | ||||
| */ | ||||
| 
 | ||||
| UPDATE   | ||||
|     tps.map_rm | ||||
| SET  | ||||
|     regex =  | ||||
|     $j$ | ||||
|     { | ||||
|         "name":"First 20", | ||||
|         "description":"pull first 20 characters from description for mapping", | ||||
|         "defn": [ | ||||
|             { | ||||
|                 "key": "{Memo}", | ||||
|                 "field":"f20", | ||||
|                 "regex": ".{1,20}", | ||||
|                 "flag":"", | ||||
|                 "retain":"y" | ||||
|             } | ||||
|         ], | ||||
|         "function":"extract", | ||||
|         "map":"yes", | ||||
|         "where": [ | ||||
|             { | ||||
|             } | ||||
|         ] | ||||
|     } | ||||
|     $j$::jsonb | ||||
| WHERE srce = 'HUNT' | ||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| @ -187,7 +187,8 @@ SET default_with_oids = false; | ||||
| 
 | ||||
| CREATE TABLE log ( | ||||
|     id integer NOT NULL, | ||||
|     rec jsonb | ||||
|     rec jsonb, | ||||
|     post_stmp timestamp with time zone DEFAULT now() | ||||
| ); | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user