Created
August 23, 2020 11:43
-
-
Save Benjaminhu/28df2417e96f579568ceade9c9768b25 to your computer and use it in GitHub Desktop.
PostgreSQL self-check config insert template
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 | |
config (id, host, section, name, value) | |
SELECT | |
nextval('seq_config'::text), new.host, new.section, new.name, new.value | |
FROM ( | |
SELECT DISTINCT host, '<SECTION>' AS section, '<NAME>' AS name, '<VALUE>' AS value FROM config | |
) AS new | |
WHERE NOT EXISTS ( | |
SELECT notexists.host | |
FROM config AS notexists | |
WHERE notexists.section = new.section AND notexists.name = new.name AND notexists.host = new.host | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment