You have a couple syntax errors and a totally superfluous/misleading comment. So:
- Postgres syntax does not accept a
where clause within the when matched phase. Move it into the on phase.
- The
update within the when matched phase must refer to only the table named in the into clause; therefore do not alias the column names.
- Finally this looks like it was originally an Oracle statement. The comment ( /*+ ... */) is how Oracle indicates a hint to its optimizer. In Postgres it's just does nothing and does nothing except perhaps cause confusion.
Taking all this your query becomes:
MERGE INTO psx_cluster_audit_t_1 a
USING psx_cluster_cross_ref_t_1 b
ON (
a.psx_id = b.RECORD_ID
AND a.PSX_BATCH_ID = b.PSX_BATCH_ID
AND b.psx_batch_id = '2411121519014999'
and a.mpc_new IS NULL -- where clause from WHEN MATCHED Phased
)
WHEN MATCHED THEN
UPDATE SET mpc_new = b.mpc;
NOTE Not tested. No table description (ddl) nor test data supplied.
WHEREclause inMERGE. That and the comment in the statement make me believe that you are trying to use aMERGEstatement for a different RDBMS.