Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have store the below Sql query in Oracle table.
Table_Name: Sql_Template
Column1:Emp
Column2: "Select Code from "+context.column1+" where code=01"
Job Flow:
tOracleInput_1 --> tmap --> tflowtoiterate -->tjavaflex ------------------> toracleInput_2 ---->tmap ---> tlogrow
OncomponentOk
In toracleinput_1 component, I have wrote the below query,
"select column1,column2 from sql_template"
In tjavaflex component, I have wrote the below variables,
context.column1 = ((String)globalMap.get("out1.column1"));
context.column2 = ((String)globalMap.get("out1.column2"));
In toracleinput_2 component, I have wrote the below one,
context.column2
Error Message:
[FATAL]: flexmetrics.copy_of_t_flx_stage_delta_load_process_0_1.T_Stage_Delta_Load_Process - tDBInput_1 ORA-00900: invalid SQL statement
java.sql.SQLSyntaxErrorException: ORA-00900: invalid SQL statement
It is not taking the context values in the second db component.
Please help to resolve the issue. It would be very helpful for me.
Appreciate your immediate response.
Thanks a lot.
Hi,
It means that context.column2 is not correctly populated with values. Could you please print this variable and see the value it is holding? It will give you an idea whether it is not having any value or it is having wrong column name.
I hope it will give you a breakthrough for your problem. If the answer has helped you, please mark the topic as resolved? Kudos are also welcome 🙂
Warm Regards,
Nikhil Thampi
Helo Everyone,
Please provide an update on the above question.
Regards,
Dhanabalan
Hi,
Could you please share a screen shot of the job for the above flow? Please check tflowtoiterate is having the mapping of columns in correct manner and print the data to verify whether the data is coming?
Warm Regards,
Nikhil Thampi
Hi Nikhil,
Thanks for your reply.
When I pass the exact below query in toracleinput_2 component instead of context.column2,
"SELECT CAND_CODE FROM "+context.Target_Table_Name+" WHERE CAND_CODE='C343j'"
m getting the correct value. When I use context, then m getting error.
Hi,
It means that context.column2 is not correctly populated with values. Could you please print this variable and see the value it is holding? It will give you an idea whether it is not having any value or it is having wrong column name.
I hope it will give you a breakthrough for your problem. If the answer has helped you, please mark the topic as resolved? Kudos are also welcome 🙂
Warm Regards,
Nikhil Thampi
Hi Nikhil,
In tjavaflex, I use the below function to replace the context value in "Select" query.
stmt=((String)globalMap.get("out1.column2"));
stmt=stmt.replace("context.column1",context.column1);
context.column2 =stmt;
m getting the expected values.
Thank you so much your inputs.
Regards,
Dhanabalan
Hi Dhanabalan,
Happy to know that the tip helped you to resolve your issue.
Enjoy programming in Talend 🙂
Warm Regards,
Nikhil Thampi