Is it possible to perform an update statement in sql, but only update if the updates are different?
for example
if in the database, col1 = \"hello\"
Old question but none of the answers correctly address null
values.
Using <> or != will get you into trouble when comparing values for differences if there are is potential null in the new or old value to safely update only when changed use the is distinct from
operator in Postgres. Read more about it here
This is possible with a before-update trigger.
In this trigger you can compare the old with the new values and cancel the update if they don't differ. But this will then lead to an error on the caller's site.
I don't know, why you want to do this, but here are several possibilities: