Skip to main content

Modifying the WAEvent data array using replace functions

When a CDC reader's output is the input of a writer, you may insert a CQ between the two to modify the WAEvent's data array using the following functions. This provides more flexibility when replicating data.

Note

When you specify a table or column name that contains special characters, use double quotes instead of single quotes and escape special characters as detailed in Using non-default case and special characters in table identifiers.Using non-default case and special characters in table identifiers

replaceData()
replaceData(WAEvent s, String 'columnName', Object o)

For input stream s, replaces the data array value for a specified column with an object. The object must be of the same type as the column.

For example, the following would replace the value of the DESCRIPTION column with the string redacted:

CREATE CQ replaceDataCQ
INSERT INTO opStream
SELECT replaceData(s,'DESCRIPTION','redacted')
FROM OracleReaderOutput s;

Optionally, you may restrict the replacement to a specific column:

replaceData(WAEvent s, String 'tableName', String 'columnName', Object o)
replaceString()
replaceString(WAEvent s, String 'findString', String 'newString') 

For input stream s, replaces all occurrences of findString in the data array with newString. For example, the following would replace all occurrences of MyCompany with PartnerCompany:

CREATE CQ replaceDataCQ
INSERT INTO opStream
SELECT replaceString(s,'MyCompany','PartnerCompany')
FROM OracleReaderOutput s;
replaceStringRegex()
replaceStringRegex(WAEvent s, String 'regex', String 'newString')

For input stream s, replaces all strings in the data array that match the regex expression with newString. For example, the following would remove all whitespace:

CREATE CQ replaceDataCQ
INSERT INTO opStream
SELECT replaceStringRegex(s,’\\\\s’,’’)
FROM OracleReaderOutput s;

The following would replace all numerals with x:

CREATE CQ replaceDataCQ
INSERT INTO opStream
SELECT replaceStringRegex(s,’\\\\d’,’x’)
FROM OracleReaderOutput s;