Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
I am trying to get the data from a flat file (in this case there are no delimiters, they are fixed rows), for example:
DATEVALUEDESCRIPTION
2017020320000EFFECTIVEPAY
In a tJavaRow I am applying some validations of structure and depending on the result, I want to send the data to insert it into an ORACLE database. So, for example, I validate that the text "20170203" is a valid date and if it is a valid date I want to send it by an output X to store it with an prepared statement in some table, but if it is not a valid date then I want to send it by another Output to perform an insert with another component in a different table that will log the errors. However, I can not find the way to specify more than one output with the componet.
Could anyone help me, please?
rana.abhimanyu90 wrote:
As rhall_2.0 has mentioned using tmap variables, you can set flags(boolean vars) based on your validation requirements and create multiple outputs for tmap and based on those flag values for each row pass the value in respective output flows.
xdshi wrote:
Hi,
From your description, you can use connection type "RunIf" which triggers a subjob or component in case the condition defined is met.
tfileinput-->tjavarow-->runif(valid data)-->inputrow-->output
-->runif(invalid data)-->inputrow-->output_2
Best regards
Sabrina
rhall_2.0 wrote:
There is an easy way of doing this. First of all, don't use the tJavaRow for your validation logic. I'm assuming you are doing this because you have a Java background. If so, wrap your logic into a routine (a Java class using a static methods) and validate the data inside a tMap. This allows multiple outputs where you can easily specify logic to indicate exactly where you want the data to go. This tutorial from Talend might help https://help.talend.com/search/all?query=tMap
rana.abhimanyu90 wrote:
As rhall_2.0 has mentioned using tmap variables, you can set flags(boolean vars) based on your validation requirements and create multiple outputs for tmap and based on those flag values for each row pass the value in respective output flows.
dazbellboy wrote:
rana.abhimanyu90 wrote:
As rhall_2.0 has mentioned using tmap variables, you can set flags(boolean vars) based on your validation requirements and create multiple outputs for tmap and based on those flag values for each row pass the value in respective output flows.
To everyone, thank you very much. I applied all your advices, it works fine... But rhall_2.0, I decided put all the validations into a tJavaRow, it seems easier... maybe it's not good for portability but I can manage the Exceptions easily.
https://www.talendforge.org/forum/img/members/411227/mini_blob_20170323-1857.png
https://www.talendforge.org/forum/img/members/411227/mini_blob_20170323-1858.png
https://www.talendforge.org/forum/img/members/411227/mini_blob_20170323-1900.png