The following bug has been logged on the website:
Bug reference: 16474
Logged by: Dmitry Ignatyev
Email address: d.a.ignatyev@yandex.ru
PostgreSQL version: 12.2
Operating system: Windows 10
Description:
Hey, guys,
A few lines of SQL to clarify the situation:
/* Here we make sure there is a value in parent table */
select source from shelf.r_source where source = 'PPDM39RNEX' \gset
/* And here we try to use it in an insert */
INSERT INTO ppdm.ppdm_rule_remark
(rule_id,
remark_type,
remark_seq_no,
remark_date,
"source")
VALUES
(:'ppdm_rule_id',
:'remark_type',
nextval('shelf.id_sequence'),
NOW(),
:'source');
This kind of code produces an SQLSTATE 23503
START TRANSACTION
psql:rule_run.sql:43: ОШИБКА: INSERT или UPDATE в таблице
"ppdm_rule_remark" нарушает ограничение внешнего ключа "prr_r_s_fk"
ПОДРОБНОСТИ: Ключ (source)=(PPDM39RNEX) отсутствует в таблице "r_source".
ROLLBACK
This is a foreign key violation message in Russian reporting an absence of
an existing value PPDM39RNEX.
Any quick workaround?
Best regards, Dmitry