From d630cccd89389f274df1527a620407ad9e1e8680 Mon Sep 17 00:00:00 2001 From: "shimoda.m@nds-tyo.co.jp" Date: Thu, 26 Oct 2023 14:08:25 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E6=8C=87=E6=91=98=E6=BC=8F=E3=82=8C=E3=81=AE=E5=8F=8D=E6=98=A0?= =?UTF-8?q?=E3=80=82=E8=A3=BD=E5=93=81=E6=8C=87=E6=A8=99=E3=81=AFPK?= =?UTF-8?q?=E3=81=8C2=E3=81=A4=E3=81=82=E3=82=8B=E3=81=AE=E3=81=A7?= =?UTF-8?q?=E3=80=81=E6=8C=87=E5=AE=9A=E3=81=97=E3=81=A6=E5=8F=96=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...crm_distribution_Product_Metrics_vod__c.sql | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/rds_mysql/stored_procedure/internal02/crm_distribution_Product_Metrics_vod__c.sql b/rds_mysql/stored_procedure/internal02/crm_distribution_Product_Metrics_vod__c.sql index 629ce9a5..cb6f98bd 100644 --- a/rds_mysql/stored_procedure/internal02/crm_distribution_Product_Metrics_vod__c.sql +++ b/rds_mysql/stored_procedure/internal02/crm_distribution_Product_Metrics_vod__c.sql @@ -7,16 +7,18 @@ SQL SECURITY INVOKER BEGIN -- 振り分けスキーマ -DECLARE distribution_schema VARCHAR(64); +DECLARE distribution_schema VARCHAR(20); -- 振り分けカラム -DECLARE target_column_value VARCHAR(64); +DECLARE target_column_value VARCHAR(100); -- 振り分け先テーブルID DECLARE temp_table_id VARCHAR(18); +-- 振り分け先テーブルのSystemModstamp +DECLARE temp_system_modstamp DATETIME; -- カーソルフェッチステータス DECLARE fetch_done BOOLEAN DEFAULT FALSE; -- カーソル設定 -DECLARE table_cursor CURSOR FOR SELECT Id, medaca_parent_msj_product_classification__c FROM internal02.crm_Product_Metrics_vod__c; +DECLARE table_cursor CURSOR FOR SELECT Id, SystemModstamp, medaca_parent_msj_product_classification__c FROM internal02.crm_Product_Metrics_vod__c; DECLARE CONTINUE HANDLER FOR NOT FOUND SET fetch_done = TRUE; -- エラー処理 @@ -67,11 +69,12 @@ SET @upsert_statement_base = FROM internal02.crm_Product_Metrics_vod__c AS internaltb WHERE - internaltb.Id = ? + internaltb.Id = ? + AND internaltb.SystemModstamp = ? ON DUPLICATE KEY UPDATE IsDeleted = internaltb.IsDeleted, Name = internaltb.Name, CreatedDate = internaltb.CreatedDate, CreatedById = internaltb.CreatedById, LastModifiedDate = internaltb.LastModifiedDate, - LastModifiedById = internaltb.LastModifiedById, SystemModstamp = internaltb.SystemModstamp, + LastModifiedById = internaltb.LastModifiedById, MayEdit = internaltb.MayEdit, IsLocked = internaltb.IsLocked, LastViewedDate = internaltb.LastViewedDate, LastReferencedDate = internaltb.LastReferencedDate, Account_vod__c = internaltb.Account_vod__c, Awareness__c = internaltb.Awareness__c, Selling_Stage__c = internaltb.Selling_Stage__c, @@ -109,7 +112,7 @@ OPEN table_cursor; -- ループ TableCursorLoop: LOOP -- スキーマ取得 - FETCH table_cursor INTO temp_table_id, target_column_value; + FETCH table_cursor INTO temp_table_id, temp_system_modstamp, target_column_value; -- 終了条件ループ抜き IF fetch_done THEN @@ -118,12 +121,13 @@ TableCursorLoop: LOOP SET @distribution_schema = internal02.get_distribution_to_schema('crm_Product_Metrics_vod__c', 'medaca_parent_msj_product_classification__c', target_column_value); SET @temp_table_id = temp_table_id; + SET @temp_system_modstamp = temp_system_modstamp; SET @upsert_statement = REPLACE(@upsert_statement_base, "$$distribution_schema$$", @distribution_schema); -- UPSERT実行 PREPARE stmt FROM @upsert_statement; - EXECUTE stmt USING @temp_table_id; + EXECUTE stmt USING @temp_table_id, @temp_system_modstamp; DEALLOCATE PREPARE stmt; END LOOP;