This example shows how to look up values from a table in the target database and replicate query results to the target table of a replication.
The following figure shows how the source table columns and virtual column map to the target table columns:
The lookup_department SQL expression retrieves a department name from a lookup table in the target database by using the REDO value of the DEPARTMENT_ID column in the source table:
(SELECT DEPARTMENT FROM DEPARTMENTS WHERE ID=:NEW.DEPARTMENT_ID)
The result of the query is replicated to the DEPARTMENT column in the target table.
The lookup table must be in the target database because the SQL Script Engine executes SQL expressions on the target.