Created
August 26, 2018 20:58
-
-
Save danielfone/c77928fe89ea0ca0fb56846edbfcb66f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSERT INTO reports (reference, program_id, generation_time, version) | |
SELECT | |
i.reference | |
programs.id AS program_id, | |
nullif(i.generation_time, '')::timestamp AS generation_time, | |
nullif(i.version, '')::numeric AS version, | |
-- etc | |
FROM imported_reports i | |
JOIN programs ON programs.reference = i.program_reference | |
ON CONFLICT (external_id) DO UPDATE SET | |
reference = excluded.reference | |
program_id = excluded.program_id, | |
generation_time = excluded.generation_time, | |
version = excluded.version | |
-- etc | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment