Update

11 views
Skip to first unread message

Tomasz Dubiel

unread,
May 15, 2023, 7:07:21 AM5/15/23
to firebird-support
Hello.
Is there a simpler solution than:
  select column
  from table
  where ....
  into :TEST;
  if (TEST is distinct from VALUE) then 
    update table
    set value = :VALUE
    where ...;

to perform update only if it would change something?
Best regards.

Mark Rotteveel

unread,
May 15, 2023, 7:11:15 AM5/15/23
to firebird...@googlegroups.com
Assuming tables in both SELECT and UPDATE are the same table, you can use:

update table
set column = :VALUE
where column is distinct from :VALUE
AND (conditions from old select where)
AND (conditions from old update where)

(and of course, prune duplicate conditions)
--
Mark Rotteveel

Tomasz Tyrakowski

unread,
May 15, 2023, 7:13:02 AM5/15/23
to firebird...@googlegroups.com
Is the obvious solution:

UPDATE table
set value = :VALUE
where ... and value is distinct from :VALUE;

not feasible for some reason in your scenario?

regards
Tomasz


Tomasz Dubiel

unread,
May 15, 2023, 7:13:42 AM5/15/23
to firebird-support
Yeah, sorry and thanks. Silly question :-D
Reply all
Reply to author
Forward
0 new messages