UPDATE TR_SEARCH_PATTERN SET
  PREFERENCE = '0',
  UPDATE_DATETIME = /*:DateTime*/TO_DATE('20091224000000','YYYYMMDDHH24MISS'),
  UPDATE_ID = /*:Uid*/'nakayama',
  VERSION = CASE WHEN VERSION = 999999 THEN 1 ELSE VERSION + 1 END
WHERE
  GID = /*:Gid*/'GID'
  AND INSERT_ID = /*:Uid*/'nakayama'
  AND PREFERENCE = '1'
  AND VERSION > 0
