Created
August 16, 2017 12:52
-
-
Save igilfanov/4df5e90d8a88d653132746a223639f45 to your computer and use it in GitHub Desktop.
This file contains 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
CREATE OR REPLACE FUNCTION trigger_fooview_before_insert() | |
RETURNS trigger AS $$ | |
DECLARE _q varchar; | |
BEGIN | |
_q := (SELECT execute(('CREATE TABLE IF NOT EXISTS sch.foo (i integer')::text) WHERE NOT EXISTS(SELECT * FROM information_schema.tables WHERE table_schema = 'sch' AND table_name = 'foo')) ; | |
EXECUTE 'INSERT INTO sch.foo VALUES('|| NEW.i::text ||')'; | |
RETURN NEW; | |
END; | |
$$ LANGUAGE plpgsql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment