Procedure
-
Click the Validation Rules tab
in the Component view of tMysqlOutput.
-
Select the Use an existing validation
rule check box to apply the validation rule to the
component.
-
In the Validation Rule Type
list, select Repository and click the
three-dot button to select the validation rule from the Repository Content window.
-
Right-click tMysqlOutput, select in the menu and drag to tLogRow to create a reject link between the two
components.
If you have enabled the Reject link option
for this validation rule you can retrieve the rejected data to the reject
flow.
-
Double-click the tJava component
to display its Basic settings.
-
In the Code field, type in the code
that will display the number of updated, inserted, and rejected lines
processed:
System.out.println("Updates: "+((Integer)globalMap.get("tMysqlOutput_1_NB_LINE_UPDATED"))+"\nInserts:
"+((Integer)globalMap.get("tMysqlOutput_1_NB_LINE_INSERTED"))+"\nRejects:
"+((Integer)globalMap.get("tLogRow_1_NB_LINE")));
-
Save your Job and press F6 to run
it.
Results
Valid data is inserted or updated in the database table and the console
displays the rows rejected by the validation rule, along with the number of updates,
inserts and rejects processed in the Job.