Creating binary error codes to store multiple test results
Note
Prior to doing this exercise, it is recommended that you first jump forward to Chapter 4, Mapping Data, and do the exercises related to ternary operators and using variables in tMap
.
Sometimes, it is desirable to perform multiple checks on a row at the same time, so that when a row is rejected, all of the problems with the data can be identified from a single error message. An excellent method of recording this is to create a binary error code.
A binary error code is a binary number, where each of the digit position represents the result of a validation test: 0 being pass and 1 being fail.
For example, 1101 = failed test 1 (rightmost digit), test 3 and test 4 and passed test 2. This binary value can be held as a decimal integer, in this case 13.
Getting ready
Open the job jo_cook_ch03_0070_binaryErrorCode
.
How to do it…
Open
tMap
and create six newInteger
type variables:nameTest
,dateOfBirthTest
,timestampTest
,ageTest
,countryOfBirthTest...