How to use SQL expressions in tDBOutput or tJDBCOutput component?
Hello,
I need to apply an SQL function on inserting rows in tJDBCOutput component.
I have attached the screen shot of where I am looking for a solution.
I need to use an SQL function (for e.g. LEFT) and I want to pass parameter to this SQL function from Talend rows.
As per the documentation reference, I just need to place the reference column name as shown in the snapshot but it gives error during execution. How can I achieve this? Did anybody use additional columns with SQL expressions?
This is important and urgent for me. Please respond soon if you have any answer.
I am not sure what is the problem, but
Try small work around
- Use tJavaRow after tMap.. assign value if col2 to context variable
- Use "LEFT(context.variable,2)" in the expression in tJDBCOutput and check again
Someone from Talend will make the POC with Vertica and respond you again.
Vaibhav
Thanks for the suggestion. -LEFT(context.variable, 2) is not working as usual. Talend takes context.variable as a literal - I tried "LEFT(" + context.variable + ",2)". but it is not functioning properly as it should. Query generator replaces col2 value with null!. Does it have to do with underlying database i.e. Vertica?
Yes. And technically and logically that should be possible. That is the reason we have REPLACE option along with AFTER and BEFORE in Additional Columns.
just another try.. create context variable as context.vQuery as string datatype and then take tJava component and write your SQL statement along with variable which carry the actual value. print context.vQuery variable and check whether query has right values or not. if yes then pass same context.vQuery to db component to execute. if values are wrong then check which value is coming wrong and then do the needful. if you already tried this solution then ignore it.