I have two same tables from two different schema, db link between schema already created. The table in schema B (old) need to be merged to schema A(new). The table structure between 2 schemas are identical, except an additional timestamp column exist in schema A.The timestamp value is defaulted as SYSDATE when merge.
When i tried to run the following script in schema B, it complains with
ORA-00904: "A"."LAST_UPDATED_TIMESTAMP": invalid identifier
MERGE INTO LOOKUP_RANGE A
USING (SELECT RANGE_NAME,RANGE_TYPE,RANGE_MIN,RANGE_MAX,RANGE_DESC FROM LOOKUP_RANGE) B
ON (A.RANGE_NAME = B.RANGE_NAME AND A.RANGE_TYPE = B.RANGE_TYPE)
WHEN MATCHED THEN UPDATE SET A.RANGE_MIN = B.RANGE_MIN, A.RANGE_MAX = B.RANGE_MAX,A.LAST_UPDATED_TIMESTAMP = SYSDATE,A.RANGE_DESC = B.RANGE_DESC
WHEN NOT MATCHED THEN INSERT (A.RANGE_MIN,A.RANGE_MAX,A.LAST_UPDATED_TIMESTAMP,A.RANGE_DESC) VALUES (A.RANGE_MIN,A.RANGE_MAX,SYSDATE,A.RANGE_DESC);
The key column in ON is the primary key of table. Am I execute in wrong schema? It should run in schema A?