Re: how do I capture conflicting rows

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: how do I capture conflicting rows
Дата
Msg-id 20230515111554.2a2q3hg2b4s5l7wh@alvherre.pgsql
обсуждение исходный текст
Ответ на how do I capture conflicting rows  (Nikhil Ingale <niks.bgm@gmail.com>)
Список pgsql-admin
On 2023-May-15, Nikhil Ingale wrote:

> Hi All,
> 
> The following query inserts the rows by ignoring the rows that has
> conflicts.
> 
> INSERT INTO test (id,name,age,branch) SELECT * FROM student ON CONFLICT DO
> NOTHING;
> 
> How do I capture the conflicting records to a file while non conflicting
> records are inserted to the table?

It sounds like you want a new feature:

INSERT INTO test (...) SELECT * FROM student
  ON CONFLICT EXECUTE FUNCTION do_your_stuff(excluded);

Sounds like it could be useful, but somebody would have to design it
fully and implement it.

Or maybe just

INSERT INTO test (...) SELECT * FROM student
  ON CONFLICT DO NOTHING RETURNING excluded.*;

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"Now I have my system running, not a byte was off the shelf;
It rarely breaks and when it does I fix the code myself.
It's stable, clean and elegant, and lightning fast as well,
And it doesn't cost a nickel, so Bill Gates can go to hell."



В списке pgsql-admin по дате отправления:

Предыдущее
От: Laurenz Albe
Дата:
Сообщение: Re: Options for more aggressive space reclamation in vacuuming?
Следующее
От: Scott Ribe
Дата:
Сообщение: Re: how do I capture conflicting rows