FLDCHG is used to check if a fields value has changed based on the before and/or after image of a record.
FLDCHG is commonly used to determine if a record or part of a records should be propagated downstream. For example, consider the case where a source IMS database stores the address of person in the person segment, and a target relational database stores addresses in a separate table from the person table. The address record would only need to be altered if a field in the address group has changed, a new person record is created, or an old person record has been deleted on the source.
IMSCDC: Unlike CDCBEFORE, FLDCHG looks directly into the incoming data stream at field’s offset and compares for the length of the fld. This data has not been altered, converted, translated or validated in any way.
Other CDC formats: Equivalent to coding: IF (SOURCE.FIELD != CDCBEFORE(SOURCE.FIELD)) The data has been altered, converted, translated and validated according to default and user specified rules.
By default, FLDCHG will return TRUE unless there is an error or there is no change in the before and after images of the field. Non-CDC data is treated like an insert so the result of FLDCHG will always be TRUE.
Category
Boolean
Syntax
FLDCHG(column_name)
Parameter and Description
Parameter | Description |
---|---|
column_name | This is the name of the column who’s value needs to be checked. |
Example
IF FLDCHG(SOURCE.FIELD) = TRUE
{
TARGET.CHANGE_FLAG = 1
}
ELSE
{
TARGET.CHANGE_FLAG = 0
}
IF FLDCHG(SOURCE.ADDRESS-GROUP) = TRUE
{
ADDRESS_TABLE.PERSON_ID = SOURCE.PERSON_ID
ADDRESS_TABLE.ADDRESS1 = SORUCE.ADDRESS1
ADDRESS_TABLE.ADDRESS2 = SORUCE.ADDRESS2
ADDRESS_TABLE.CITY = SORUCE.CITY
ADDRESS_TABLE.STATE = SORUCE.STATE
ADDRESS_TABLE.ZIP = SORUCE.ZIP
}