By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
1 rows affected
1 rows affected
| a | b |
|---|---|
| x | y |
| null | null |
| ab |
|---|
| x |
| y |
ERROR: duplicate key value violates unique constraint "tbl_ab_pkey"
DETAIL: Key (ab)=(x) already exists.
CONTEXT: SQL statement "INSERT INTO tbl_ab(ab)
SELECT NEW.a WHERE NEW.a IS NOT NULL -- NULL is allowed (?)
UNION ALL
SELECT NEW.b WHERE NEW.b IS NOT NULL"
PL/pgSQL function trg_tbl_insbef() line 3 at SQL statement
ERROR: duplicate key value violates unique constraint "tbl_ab_pkey"
DETAIL: Key (ab)=(y) already exists.
CONTEXT: SQL statement "INSERT INTO tbl_ab(ab)
SELECT NEW.a WHERE NEW.a IS NOT NULL -- NULL is allowed (?)
UNION ALL
SELECT NEW.b WHERE NEW.b IS NOT NULL"
PL/pgSQL function trg_tbl_insbef() line 3 at SQL statement
ERROR: duplicate key value violates unique constraint "tbl_ab_pkey"
DETAIL: Key (ab)=(x) already exists.
CONTEXT: SQL statement "INSERT INTO tbl_ab(ab)
SELECT NEW.a WHERE NEW.a IS NOT NULL -- NULL is allowed (?)
UNION ALL
SELECT NEW.b WHERE NEW.b IS NOT NULL"
PL/pgSQL function trg_tbl_insbef() line 3 at SQL statement
ERROR: duplicate key value violates unique constraint "tbl_ab_pkey"
DETAIL: Key (ab)=(z) already exists.
CONTEXT: SQL statement "INSERT INTO tbl_ab(ab)
SELECT NEW.a WHERE NEW.a IS NOT NULL -- NULL is allowed (?)
UNION ALL
SELECT NEW.b WHERE NEW.b IS NOT NULL"
PL/pgSQL function trg_tbl_insbef() line 3 at SQL statement