Trabajando en un pequeño experimento, se me ha ocurrido un insert idempotente:

insert into foo (bar) (select ‘bar_value’ as bar where not exists (select 1 from foo where bar = ‘bar_value’));

(la sintaxis es de PostgreSQL, pero supongo que es adaptable a otras bases de datos). Igual intento adaptarlo a hacer upserts.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.