I want to do something like this in a PL/pgSQL function in Postgres 9.6:
INSERT INTO table1 (id, value) VALUES (1, \'a\') ON CONFLICT DO NOTHING;
--- If the
Maybe you mean something like this?
INSERT INTO table1 (id, value) VALUES (1, 'a') ON CONFLICT DO NOTHING;
--- If the above statement didn't insert a new row
--- because id of 1 already existed,
--- then run the following statements
affected_rows := SQL%ROWCOUNT;
IF affected_rows = 0 THEN
INSERT INTO table2 (table1_id, value) VALUES (1, 'a');
UPDATE table3 set (table1_id, time) = (1, now());
END IF