The beautifier is not working correctly for a merge statement. The "ON" statement is putting the "AND" statements on one line instead of multiple.
It is doing this.
But should do this:
It is doing this.
SQL:
MERGE INTO wh_user.inventory_total IT
USING (SELECT p_period P,
p_year Y,
IC.dbctr C,
IC.dbitem_number I
FROM wh_user.inventory_center IC,
op_user.center C1,
op_user.lu_center_type LCT
WHERE IC.dbusage_group IS NOT NULL
AND C1.dbctr = IC.dbctr
AND LCT.dbtype = C1.dbtype
AND LCT.dbtype_flag = 1) Q
ON (IT.dbperiod = Q.P AND IT.dbyear = Q.Y AND IT.dbctr = Q.C AND IT.dbitem_number = Q.I)
WHEN NOT MATCHED THEN
INSERT
(IT.dbperiod,
IT.dbyear,
IT.dbctr,
IT.dbitem_number)
VALUES
(Q.P,
Q.Y,
Q.C,
Q.I);
But should do this:
SQL:
MERGE INTO wh_user.inventory_total IT
USING (SELECT p_period P,
p_year Y,
IC.dbctr C,
IC.dbitem_number I
FROM wh_user.inventory_center IC,
op_user.center C1,
op_user.lu_center_type LCT
WHERE IC.dbusage_group IS NOT NULL
AND C1.dbctr = IC.dbctr
AND LCT.dbtype = C1.dbtype
AND LCT.dbtype_flag = 1) Q
ON (IT.dbperiod = Q.P AND
IT.dbyear = Q.Y AND
IT.dbctr = Q.C AND
IT.dbitem_number = Q.I)
WHEN NOT MATCHED THEN
INSERT
(IT.dbperiod,
IT.dbyear,
IT.dbctr,
IT.dbitem_number)
VALUES
(Q.P,
Q.Y,
Q.C,
Q.I);