Using Java for condition code generation
If we really want code
generation to be flexible, we need to have the ability to choose what code is generated based on external elements. This means that at code generation time, we need to have the ability to chose among different portions of code. If we were to write pure Java code, an If
statement would give us exactly what we are looking for. So our approach will be just this: take advantage of the fact that we can execute Java code to control code generation and always generate the proper code as needed.
Getting ready
For this recipe, we will reuse the KM that was created in the previous recipe. If you did not follow the necessary steps to create the KM, you will need to perform steps 1 through 6 of the previous recipe: Using Java Variables in KMs.
How to do it...
Right-click on the
IKM SQL Control Append with Variable KM
to duplicate it. Then rename the copy ofIKM SQL Control Append with Variable
KM toIKM SQL Control Append with Variable and...