<insert id="mergeOverride">
MERGE INTO @@schema.invods_asin_weekly_forecasts T1
USING (
SELECT #{asin} asin , #{organizationalUnitId} organizational_unit_id , #{forecastTargetDay} forecast_target_day , #{forecastTypeCode} forecast_type_code
FROM DUAL) T2
ON ( T1.asin = T2.asin
AND T1.organizational_unit_id = T2.organizational_unit_id
AND T1.forecast_type_code = T2.forecast_type_code
AND T1.forecast_target_day = T2.forecast_target_day )
WHEN MATCHED THEN
UPDATE
SET
T1.quantity =#{overrideQuantity},
T1.override_logon_id =#{overrideLogonId},
T1.last_updated =#{lastUpdated}
WHEN NOT MATCHED THEN
INSERT (T1.asin, T1.organizational_unit_id, T1.gl_product_group, T1.forecast_type_code, T1.forecast_target_day,
T1.forecast_creation_day, T1.quantity, T1.forecast_dist_type_id, T1.forecast_dist_param_1,
T1.forecast_dist_param_2, T1.last_updated, T1.override_logon_id) VALUES
(#{asin},#{organizationalUnitId},#{gl},#{forecastTypeCode},#{forecastTargetDay},
#{forecastCreationDay},#{overrideQuantity},#{forecastDistTypeId},#{forecastDistParm1},
#{forecastDistParm2},#{lastUpdated},#{overrideLogonId})
</insert>
MERGE INTO @@schema.invods_asin_weekly_forecasts T1
USING (
SELECT #{asin} asin , #{organizationalUnitId} organizational_unit_id , #{forecastTargetDay} forecast_target_day , #{forecastTypeCode} forecast_type_code
FROM DUAL) T2
ON ( T1.asin = T2.asin
AND T1.organizational_unit_id = T2.organizational_unit_id
AND T1.forecast_type_code = T2.forecast_type_code
AND T1.forecast_target_day = T2.forecast_target_day )
WHEN MATCHED THEN
UPDATE
SET
T1.quantity =#{overrideQuantity},
T1.override_logon_id =#{overrideLogonId},
T1.last_updated =#{lastUpdated}
WHEN NOT MATCHED THEN
INSERT (T1.asin, T1.organizational_unit_id, T1.gl_product_group, T1.forecast_type_code, T1.forecast_target_day,
T1.forecast_creation_day, T1.quantity, T1.forecast_dist_type_id, T1.forecast_dist_param_1,
T1.forecast_dist_param_2, T1.last_updated, T1.override_logon_id) VALUES
(#{asin},#{organizationalUnitId},#{gl},#{forecastTypeCode},#{forecastTargetDay},
#{forecastCreationDay},#{overrideQuantity},#{forecastDistTypeId},#{forecastDistParm1},
#{forecastDistParm2},#{lastUpdated},#{overrideLogonId})
</insert>