Retrieving a column using the %GETCOL function (Dynamic SQL)
An example of how to retrieve a column from another table using the %GETCOL function.
This example refers to the primary (EMPLOYEE) and secondary (BRANCH,
STATE, and COUNTRY) table relationship. The table names referenced
in the examples follow the format for the CDC Replication Engine for Microsoft SQL Server and CDC Replication Engine for Sybase databases.
If you installed another CDC Replication replication
engine, see the table_name parameter in this
function for more information about specifying table names which depends
on your database.
To use the example, you must add a derived column to the MASTER.DBO.EMPLOYEE primary table and enter the specified %GETCOL function in that column.
%GETCOL(NAMEB, MASTER.DBO.BRANCH,
NO NAME
,
BRANCHB, BRANCH)
This example retrieves the NAMEB column from the MASTER.DBO.BRANCH secondary table, using the value in the BRANCH column in the primary table and the key column BRANCHB in the secondary table.
If a record in the primary table has a branch number that does not exist in the MASTER.DBO.BRANCH table, then this function returns for that record in the retrieved column.