I want to update a table called Sorels_ext from a table called Sorels. The link between them is the fkey_id of Sorels_ext equals the identity_column of the Sorels table. Thi
INSERT (SORe.fkey_id, SORe.Color)
should read:
INSERT (fkey_id, Color)
Columns in the insert list can only refer to the target table. The parser doesn't expect to see a table alias there, and doesn't know how to resolve it.
If it sees "column1", it knows it belongs to the target table. It sees "table1.column1", it doesn't know what "table1" means, since "table1" as a token is out of scope.
Try taking out the "AS" in your ") AS SOR"
I believe you have to alias your your source data like so:
USING (select SOR.identity_column,
CASE WHEN left(SOR.FPARTNO, 2) = 'BL'
THEN 'Blue'
WHEN left(SOR.FPARTNO, 2) = 'RD'
THEN 'Red'
ELSE 'White'
END from Sorels AS SOR) **AS SOR** ON (SORe.fkey_id = SOR.identity_column)