Skip to content

Instantly share code, notes, and snippets.

@denistsyplakov
Created August 16, 2023 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save denistsyplakov/8d32147b082a78b732575ba01bb38b56 to your computer and use it in GitHub Desktop.
Save denistsyplakov/8d32147b082a78b732575ba01bb38b56 to your computer and use it in GitHub Desktop.
postgres upsert returning only updated rows
-------- test upsert with where returning only updated rows-----------
create table tmp_fx(code varchar primary key, rate numeric);
insert into tmp_fx(code, rate)
values (:code, :rate)
on conflict (code) do update
set rate=excluded.rate
where tmp_fx.rate <> excluded.rate
returning code;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment