Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

store the dynamic values in context variable

Hi team,

 

I have source oracle table and there is one column called txn_date. 

 

values are:

txn_date

02-06-2017

04-06-2017

07-06-2017

04-06-2017

 

Requirement: How to create folder based on date for examples:

folder 1: c;/Txn_dt_02-06-2017/

folder 2 :c:/Txn_dt_04-06-2017/

folder 3 :c:/Txn_dt_07-06-2017/

 

But no duplicate folder even if same records with same date arrive. 

 

and is possible to store single context variable  to store unique txn_dt values?

 

Thanks

Shree

 

Labels (1)
46 Replies
TRF
Champion II
Champion II

Hi,

You can set a context variable value dynamically at runtime (context.yourVariable = "whatYouWant") but usaully for this king of usecase it's preferable to set a global variable. 

Your design process should look like:

tOracleInput -> tUniqRow (eliminates doublons on date values) -> tJavaRow (here set the desired global variable) ->  tSystem (to create directory)

 

To set the global variable, use the following:

globalMap.put("outputFolder", inuput_row.txn_date);

As there is not dedicated somponent to create an empty folder, use tSystem for this purpose with the following command:

"cmd /c mkdir " + ((String)globalMap.get("outputFolder"))

Hope this helps.

Anonymous
Not applicable
Author

Hi Shree
Do you want to store the source data to file under the folder or just create a folder without writing data?

Regards
Shong
Anonymous
Not applicable
Author

I see where @shong is going with the above. If you are intending to add data to the folder, there is no need to worry about this problem.

 

1) You cannot create a folder twice. Once it exists, it exists

2) When you want to write a file to a folder in Talend, you can set the file to create the folder if it does not already exist

 

Unless there is some other requirement here, you really do not need to worry about this.

Anonymous
Not applicable
Author

Hi Shong.

 

Sound good, if we can store records as well based on dates. ex: 4th day records-> create folder(04-06-2017)/txn_dt_4th_data.csv. similar to other days as well.

 

Means time need to store the date values in context variable in single or mutiple context variable.

 

After that, i am going to use this context variable for some excel file creation based on some columns like gender='M' etc.

 

Thanks

Shree

 

 

 

 

 

Anonymous
Not applicable
Author

Hi,

 

As per suggestion whether it will create distinct folder based on date  unique values?

 

Thanks in advance.

 

Regards

Shree

 

TRF
Champion II
Champion II

I think I gave you the answer (or not?)
Anonymous
Not applicable
Author

Hi,

 

I have tried as your input. 

 

I have facing error while creating folder using tSystem component. I have attached screen shot for references.

 

One more point rather than using tUniquerow , we can override distinct in tOracleInput itself? 

 

Error message: 

A subdirectory or file null already exists.

 

Thanks

Shree


error.PNG
cterenzi
Specialist
Specialist

The components that create output files have an option "Create directory if does not exist"

Better to use those so that the only directories created are ones with files in them. The component will only create a directory once.
Anonymous
Not applicable
Author

Hi,

 

Still i am facing same error.

 

I am attaching job for your reference. Could you please check it.

 

Thanks

Shree


mutiple_folder_creation.zip