The Query below is suited in SQL sErver. But in DB2 it does not give results:
Error is SQLCODE = -199, ERROR: ILLEGAL USE OF KEYWORD FROM.
If you want to use UPDATE rather than MERGE, you want to process only the matching records where the value will change.
UPDATE Sales_Import SI
SET SI.AccountNumber =
(SELECT RAN.AccountNumber
FROM RetrieveAccountNumber RAN
WHERE SI.LeadID = RAN.LeadID
FETCH FIRST ROW ONLY
)
WHERE SI.LeadID IN
(SELECT S2.LeadID
FROM Sales_Import S2
JOIN RetrieveAccountNumber R2
ON S2.LeadID = R2.LeadID
WHERE S2.AccountNumber <> R2.RetrieveAccountNumber
)