tps/database/deploy/reload/paycom/extract.sql

59 lines
1.2 KiB
MySQL
Raw Normal View History

2018-05-30 13:43:17 -04:00
--transactions with date in download format for constraint
COPY
(
SELECT
2018-05-30 15:10:46 -04:00
r."perd_start",
r."perd_end",
r."check_date",
r."loc_code",
r."loc_descr",
r."loc_glseg",
r."loc_over",
r."dep_code",
r."dep_descr",
r."dep_nat",
r."dep_over",
r."di_code",
r."di_descr",
r."di_glseg",
r."di_over",
r."title_code",
r."title_descr",
r."title_glseg",
r."title_over",
r."ee_code",
r."ee_glseg",
r."ee_over",
r."acct_type_code",
r."hours",
r."nat_code",
r."nat_over",
r."gl_ref",
r."gl_group",
r."gl_descr",
r."gl_code",
r."gl_amount",
r."pp_code",
r."pp_descr",
r."pp_gl",
r."pp_over",
r."transaction"
2018-05-30 13:43:17 -04:00
FROM
tps.trans
2018-05-30 15:10:46 -04:00
JOIN LATERAL jsonb_populate_record(NULL::tps.PAYCOM, rec) r ON TRUE
2018-05-30 13:43:17 -04:00
WHERE
2018-05-30 15:10:46 -04:00
srce = 'PAYCOM'
2018-05-30 13:43:17 -04:00
)
2018-05-30 15:10:46 -04:00
TO 'C:\users\ptrowbridge\downloads\PAYCOM.csv' WITH (format csv, header TRUE)
2018-05-30 13:43:17 -04:00
--source
2018-05-30 15:10:46 -04:00
SELECT DEFN FROM TPS.SRCE WHERE SRCE = 'PAYCOM'
2018-05-30 13:43:17 -04:00
--mapdef
2018-05-30 15:10:46 -04:00
SELECT jsonb_agg(row_to_json(x)::jsonb) FROM (SELECT srce, target "name", regex, seq "sequence" FROM tps.map_rm WHERE srce = 'PAYCOM') x
2018-05-30 13:43:17 -04:00
--map values
2018-05-30 15:10:46 -04:00
SELECT jsonb_agg(row_to_JSON(x)::jsonb) FROM (SELECT srce "source", target "map", retval ret_val, "map" mapped FROM tps.map_rv WHERE srce = 'PAYCOM') X
2018-05-30 13:43:17 -04:00