One Star

conditional flow of data

Hi
I have the following problem
i have to export data from a source database to either excel sheets or dB depending upon a context variable.
I tried using treplicate, but it does not have condition for the flow
I tried using tmap and put the condition in the expression filter.
This works but there is one catch
the output filename and the db conn string both are needed regardless of what the output is.
i assume this is because the flow is happening to both even if there are no rows passing through it.
so is there way to stop the flow using tjava or some other component
or is there a better solution than i am doing
Thanks
Vijay
4 REPLIES
Community Manager

Re: conditional flow of data

Hello
the output filename and the db conn string both are needed regardless of what the output is.

I don't understand you here, can you give us an example?
About the filter rows, you can use the tFilterRow component.
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: conditional flow of data

Hi
The final output is going to be only one. Either Excel or DB.
I have a context variable "OutputType" this has a value "Excel" or "DB"
I also have the file details (filename, filepath etc)and DB conn detals (server, username password etc) in the contexts
If the value is "Excel" then the output should be redirected to Excel file.
If the output is "DB" then the output should be redirected to a DB.
I populate the Context variable during runtime using a XML file and TContextLoad.
If it is Excel then i will have the "filename" and "filepath" context variables populated and the DB details blank (as i do not know it)
and if DB vice versa.
So in my scenario assume i have the output to Excel, then my DB details will be blank. if i run the job then i get an exception on the DB component.
is there a way to completely stop the flow to the DB component if the outpuy type is Excel
This is the structure of my job
TmsssqlOutput --> Tmap --> TfileinputExcel
|
v
Tmsssqlinput

Hope this is clear
One Star

Re: conditional flow of data

hello,
I have the same problem.
I need to output to either a mysql database or an excel file based on a context variable.
Any solution how this can be done.
Thanks a lot for your help,
Tawfiq
Seven Stars

Re: conditional flow of data

Have a look at this post.