Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
jbhatt1810
Contributor III
Contributor III

How to input random table name in tDBOutput "Table" field?

I have a requirement to create table with random name. How do I achieve this in talend where "Table" field will be able to generate/take random table names? For example, every time job runs, it should create table name like "Auto1". Next time it should be "Auto2".. If I am coding then usually create incremental variable and simply concat "Auto" string with that variable using for loop. How do I achieve this in Talend? See attached job screenshot.

Labels (3)
1 Solution

Accepted Solutions
madhukolli2003
Contributor III
Contributor III

Hi @Janki Bhatt​ ,

Please assign date value to a variable and call that one in the tDBOutput component .

 

 

tjava -> tfileinputExcel -> tFilterRow - > tDBOutput

 

tjava::

 

globalMap.put("current_date",TalendDate.getDate("MMDDCCYYHHmmssS"));

 

System.out.println("current_date=" + globalMap.get("current_date"));

 

tDBOutput ::

Table = "QRDA1_Auto_"+globalMap.get("current_date")

 

 

Thanks & Regards,

Madhu Kolli

 

 

 

 

 

View solution in original post

5 Replies
madhukolli2003
Contributor III
Contributor III

Hi,

Below example shows how to compose dynamic table name with current_date . 

 

 

0693p000009RHcTAAW.jpg

 

 

 

tJava::

 

globalMap.put("current_date",TalendDate.formatDate("yyyyMMdd", TalendDate.getCurrentDate()));

 

System.out.println("current_date=" + globalMap.get("current_date"));

 

 tDBOutput ::

0693p000009RHd7AAG.jpg

 

 

 

If you want to populate only sequence numbers probably you may need to create sequence in mysql and get latest value from it and append it to global variable.

 

Thanks & Regards,

Madhu Kolli

 

 

 

 

 

jbhatt1810
Contributor III
Contributor III
Author

Thank you for your reply. I updated my job per suggestion. It worked fine for few rows parsing and inserting into DB table and then in between it stopped throwing an error mentioning that table not found. Do you know why? See attached updated Job and Log. I checked the backend and mentioned table does exist but is empty with no records. Why would it throw an error for no table found though?

 

Log:

For input string: "Account #"

For input string: "IPP"

For input string: "Den Exclusion"

For input string: "Num"

Table 'valueset.qrda1_auto08262020150159908' doesn't exist

Table 'valueset.qrda1_auto08262020150159908' doesn't exist

For input string: "Denominator Exception"

Table 'valueset.qrda1_auto08262020150159908' doesn't exist

 

0693p000009RLxzAAG.png

 

 

 

 

 

 

madhukolli2003
Contributor III
Contributor III

Hi @Janki Bhatt​ ,

Please assign date value to a variable and call that one in the tDBOutput component .

 

 

tjava -> tfileinputExcel -> tFilterRow - > tDBOutput

 

tjava::

 

globalMap.put("current_date",TalendDate.getDate("MMDDCCYYHHmmssS"));

 

System.out.println("current_date=" + globalMap.get("current_date"));

 

tDBOutput ::

Table = "QRDA1_Auto_"+globalMap.get("current_date")

 

 

Thanks & Regards,

Madhu Kolli

 

 

 

 

 

jbhatt1810
Contributor III
Contributor III
Author

Yes, I realized that later. Thank you for all your help @MADHUSUDHANA kolli​ 

madhukolli2003
Contributor III
Contributor III

You Welcome !