refactor:EXISTSに変更
This commit is contained in:
parent
4a73e14bbf
commit
016e4465e5
@ -20,16 +20,21 @@ BEGIN
|
||||
-- ①-1 Salesforce側で物理削除されたデータを検出し更新する
|
||||
SET @update_end_datetime = '
|
||||
UPDATE $$target_table$$ tt
|
||||
LEFT JOIN $$target_table_all$$ tta
|
||||
ON tt.id = tta.id
|
||||
AND tt.$$target_column$$ = tta.$$target_column$$
|
||||
SET
|
||||
tt.end_datetime = CURRENT_TIMESTAMP ()
|
||||
, tt.upd_user = CURRENT_USER ()
|
||||
, tt.upd_date = CURRENT_TIMESTAMP ()
|
||||
WHERE
|
||||
tta.id IS NULL
|
||||
AND tt.end_datetime = "9999-12-31 00:00:00"
|
||||
tt.end_datetime = "9999-12-31 00:00:00"
|
||||
AND NOT EXISTS (
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
$$target_table_all$$ tta
|
||||
WHERE
|
||||
tt.id = tta.id
|
||||
AND tt.$$target_column$$ = tta.$$target_column$$
|
||||
)
|
||||
';
|
||||
SET @update_end_datetime = REPLACE(@update_end_datetime, "$$target_table$$", target_table);
|
||||
SET @update_end_datetime = REPLACE(@update_end_datetime, "$$target_table_all$$", target_table_all);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user