UPDATE "EDI"."EC_InventoryTransfer" SET "SaleStatusID"=B."SaleStatusID" FROM (SELECT "BrandName","DetailId","SaleStatusID" FROM dblink('dbname=erp2','SELECT "BrandName","DetailId","SaleStatusID" FROM "EDI"."EC_InventoryTransfer"') AS Y ("BrandName" varchar(15),"DetailId" int8,"SaleStatusID" int8)) B WHERE "EDI"."EC_InventoryTransfer"."BrandName" = B."BrandName" AND "EDI"."EC_InventoryTransfer"."DetailId"=B."DetailId";