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
The easiest and reliable way is with the especial variable FOUND, this way:
INSERT INTO table1 (id, value) values (1, ‘a’) on conflict do nothing;
IF FOUND THEN
--success
ELSE
--failure
END IF;
Here is the documentation of diagnosing a statement https://www.postgresql.org/docs/9.6/static/plpgsql-statements.html