JSON Example that Uses Multiple Tag Types
This example produces a JSON format for insert and delete events for an Oracle object. The result will be a condensed JSON string that contains the following information:
The event types are of insert and delete only.
The num1 and num2 columns of the object have a number data type.
A column that contains the creation date for the change record in the format yyyyMMdd.
The table is defined by the following Oracle DDL:
CREATE TABLE "XXX"."NUMTBL3"
("num1" NUMBER(2) NOT NULL ENABLE,
"num2" NUMBER(10),
PRIMARY KEY ("num1") …
In the PowerExchange CDC capture registrations, the table name is numtbl3_NUMTBL3.
In the custom pattern, which is defined for numtbl3_NUMTBL3, the following tags define column attribute processing:
Use the <EXCLUDE> tag to exclude all columns except for DTL__CAPXTIMESTAMP, which is the source creation timestamp for the row.
Use the <DT_SWAP> tag to define the following processing:
Convert the DTL__CAPXTIMESTAMP column, which is a “long” data type from PowerExchange CDC to a date format.
Swap the num2 column from a string data type to an int32 data type.
Use the <DT_MASK> tag to convert DTL__CAPXTIMESTAMP into the format yyyyMMdd.
Use the <DT_QUOTES> tag to define the following processing:
Explicitly state that any value for data type int32 will not have its value wrapped in double-quotation marks.
The data type string will have its value quoted with a double-quotation mark.
The data type date will have its value quoted with a double-quotation mark.
The data type binary will have its value quoted with a double-quotation mark. Even though there are no binary items produced, it is safe to include them because they are ignored in this case.
The <data_value> tag is not quoted in the syntax of the insert and delete event.
<SPECIAL_ATTRIBUTES>
<DELIMITER>NEWLINE</DELIMITER>
<REPEAT_DELIMITER>, NEWLINE</REPEAT_DELIMITER>
</SPECIAL_ATTRIBUTES>
<COLUMN_ATTRIBUTES>
# exclude columns
<EXCLUDE><column_name>*_Present</column_name></EXCLUDE>
<EXCLUDE><column_name>*_BeforeImage</column_name></EXCLUDE>
<EXCLUDE><column_name>*_BeforeImage_Present</column_name></EXCLUDE>
<EXCLUDE><column_name>DTL__CAPXACTION</column_name></EXCLUDE>
<EXCLUDE><column_name>DTL__CAPXRESTART1</column_name></EXCLUDE>
<EXCLUDE><column_name>DTL__CAPXRESTART2</column_name></EXCLUDE>
<EXCLUDE><column_name>DTL__CAPXROWID</column_name></EXCLUDE>
<EXCLUDE><column_name>DTL__CAPXUOW</column_name></EXCLUDE>
<EXCLUDE><column_name>DTL__CAPXUSER</column_name></EXCLUDE>
<EXCLUDE><column_name>INFA_SEQUENCE</column_name></EXCLUDE>
<EXCLUDE><column_name>INFA_OP_TYPE</column_name></EXCLUDE>
<EXCLUDE><column_name>INFA_TABLE_NAME</column_name></EXCLUDE>
# swap data types
<DT_SWAP><column_name>DTL__CAPXTIMESTAMP</column_name><old_data_type>long</old_data_type><new_data_type>date</new_data_type></DT_SWAP>
<DT_SWAP><column_name>num2</column_name><old_data_type>string</old_data_type><new_data_type>int32</new_data_type></DT_SWAP>
<DT_SWAP><old_data_type>integer</old_data_type><new_data_type>int32</new_data_type></DT_SWAP>
# masks
<DT_MASK><column_name>DTL__CAPXTIMESTAMP</column_name><format>yyyyMMdd</format></DT_MASK>
# dont use quotes on these data types
<DT_QUOTES><data_type>int32</data_type><quote_character></quote_character></DT_QUOTES>
# use quotes on these data types
<DT_QUOTES><data_type>string</data_type><quote_character>"</quote_character></DT_QUOTES>
<DT_QUOTES><data_type>date</data_type><quote_character>"</quote_character></DT_QUOTES>
<DT_QUOTES><data_type>binary</data_type><quote_character>"</quote_character></DT_QUOTES>
</COLUMN_ATTRIBUTES>
<INSERT_EVENT>
{ "event" : "insert", "columns" : [ <delimiter>
<REPEAT> { "column" : "<column_name>", "<column_type>" : <column_value> } </REPEAT>
]
}
</INSERT_EVENT>
<DELETE_EVENT>
{
"event" : "delete", "columns" : [ <delimiter>
<REPEAT> { "column" : "<column_name>", "<column_type>" : <column_value > } </REPEAT>
]
}
</DELETE_EVENT>
The following example shows the output for an insert event that has columns num1 = 27 and column num2 = 270:
{ "event" : "insert", "columns" : [
{ "column" : "DTL__CAPXTIMESTAMP", "date" : "20200812" } ,
{ "column" : "num1", "int32" : 27 } ,
{ "column" : "num2", "int32" : 270 } ]}