CDCBEFORE - connect_cdc_sqdata - Latest

Connect CDC (SQData) Apply engine

Product type
Software
Portfolio
Integrate
Product family
Connect
Product
Connect > Connect CDC (SQData)
Version
Latest
Language
English
Product name
Connect CDC (SQData)
Title
Connect CDC (SQData) Apply engine
Copyright
2024
First publish date
2000
Last updated
2024-12-13
Published on
2024-12-13T13:15:51.808737
Note: The @before function replaces the both CDCBEFORE and MAP_BEFORE functions.
The CDCBEFORE function applies only to changed data capture (CDC) records. It returns the before image of a source field involved in update transactions only. For deletes, inserts and non-CDC data it return the current value of the field.

CDCBEFORE does not provide access to the raw data of the before image. The before image has already been processed using default and user specified data rules. This includes data type and EXTTYPE validation, error processing and code page translations. @BEFORE is most often used to implement conditional business logic based on a change to the value of a particular source field/column. It is also used to support changes to the value of a Key field or column when replicating changes to a Relational target when using the APPLY command to write to the Target datastore.

Category

Changed Data Capture

Syntax

CDCBEFORE(<source_description>.<source_field>)

Parameter and Description
Parameter Description
<source_description>.<source_field> The source field name for the data in the before image of the CDC record.

Example 1

When a client’s account status changes from OPENED to CLOSED. Retrieve the before image content of source field SRC_FLD1 from a changed data capture record and map the result to target field T_PREV_SRC_FLD1.
T_PREV_SRC_FLD1  = CDCBEFORE(SRC_FLD1)

Example 2

Call a special process if the SOURCE.STATUS field changes from OPENED to CLOSED.
IF CDCBEFORE(SOURCE.STATUS) = 'OPEN' AND SOURCE.STATUS = 'CLOSED'
{
   CALLPROC(CLOSING)
}

Example 3

On an Update, determine if the source field SRC_FLD1 has changed and set the variable CHGFLAG to "Y" if it has otherwise set the value to "N".
Note: You can also use FLDCHG function.
CASE
WHEN CDCBEFORE(SRC_FLD1) = SRC_FLD1
{
   CHGFLAG = 'N'
}
OTHERWISE
{
   CHGFLAG  =  'Y'
}