The "returning" statement returns 0 rows, but I want the row that couldn't be inserted because of the conflict. Something I am missing there?
detail: table users_strategies got primary keys (id_strategy,id_account)
xsignalsbot=# select * from users_strategies;
id | id_strategy | id_account | risk | active
----+-------------+------------+------+--------
1 | 1 | 48 | 0.50 | t
2 | 2 | 48 | 0.25 | f
(2 rows)
xsignalsbot=# insert into users_strategies (id_strategy,id_account)
values (1,48) on conflict (id_strategy,id_account) do nothing
returning active,risk;
active | risk
--------+------
(0 rows)
DO NOTHING
does not apply to RETURNING
:
The optional RETURNING clause causes INSERT to compute and return value(s) based on each row actually inserted (or updated, if an ON CONFLICT DO UPDATE clause was used).
reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With