Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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
Hi,
Below example shows how to compose dynamic table name with current_date .
tJava::
globalMap.put("current_date",TalendDate.formatDate("yyyyMMdd", TalendDate.getCurrentDate()));
System.out.println("current_date=" + globalMap.get("current_date"));
tDBOutput ::
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
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
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
Yes, I realized that later. Thank you for all your help @MADHUSUDHANA kolli
You Welcome !