Hidden Field Example
Here is an example demonstrating all hidden fields, as it deletes all the attributes hidden="true".
<rule sequence="1">
<when>
<field hidden="true"/>
</when>
<do>
<delete>
<field hidden="true"/>
</delete>
</do>
</rule>
DATE onConvertError Example
COBOL types mapped to date, datetime, or time may cause conversion issues if the COBOL data cannot be properly represented by a type of date, datetime, or time. Hence it may be useful to have a rule to set fields to NULL when a conversion error occurs on the schemas having a field mapped to a date, datetime, or time field. Here is a rule to do that for date fields:
<rule sequence="2">
<when>
<field dbtype="date"/>
</when>
<do>
<set>
<schema OnConvertError="null"/>
</set>
</do>
</rule>
The examples below show the following rules, which will be applied in the sequence order (based on "sequence="):
bindefault Example
When the field type="NumUnsigned", add bindefault="all-spaces".
<rule sequence="100">
<when>
<field type="NumUnsigned"/>
</when>
<do>
<add>
<field bindefault="all-spaces"/>
</add>
</do>
</rule>
cbdefault Example
When the field dbtype="date", add field cbdefault="0".
<rule sequence="110">
<when>
<field dbtype="date"/>
</when>
<do>
<add>
<field cbdefault="0"/>
</add>
</do>
</rule>
onConvertError Example
When the field name="CUSTOMER_ID", set field onConvertError="null".
<rule sequence="900">
<when>
<field name="CUSTOMER_ID"/>
</when>
<do>
<set>
<field onConvertError="null"/>
</set>
</do>
</rule>
Combined onConvertError and Format Addition Example
When the field dbtype="date", add field cbdefault="0" onConvertError="null" and add field format="YYYYMMDD" cbdefault="0" onConvertError="error".
<rule sequence="1000">
<when>
<field dbtype="date"/>
</when>
<do>
<add>
<field cbdefault="0" onConvertError="null"/>
</add>
<add>
<field format="YYYYMMDD" cbdefault="0" onConvertError="error"/>
</add>
</do>
</rule>