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

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

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.
0683p000009ME8Z.png
Labels (3)
18 Replies
Anonymous
Not applicable
Author

As per screenshot, your reference column and actual column names are same? is it the case then what is the use of additional column?
It it is true, then what is the name and use of additional column?
Vaibhav
Anonymous
Not applicable
Author

My question is not about the use of additional column. My question is about how to use an SQL expression which uses an SQL function with parameter.
For your doubt: I want to apply an SQL function on col2 and use the output and don't want to use col2 coming from tMap. Please don't advise me to use the function in tMap itself as a few functions are available only in database and not in tMap.
Anonymous
Not applicable
Author

"StringHandling.LEFT(col2,2)"
Anonymous
Not applicable
Author

Thanks for your reply sanvaibhav, but I clearly asked not to advise me to use Talend functions in tMap.
I want to use an SQL function of the underlying database on incoming column.
Anonymous
Not applicable
Author

What is the error that you are getting...
It works.. pl check the screenshot.
Vaibhav
0683p000009ME8e.jpg
Anonymous
Not applicable
Author

Here is the error.
Basically, the SQL expression is not able to identify what the col2 is.
and I do have col2 declared in the Database tables.
0683p000009ME5M.png
Anonymous
Not applicable
Author

Whether your job is working without additional columns?
Anonymous
Not applicable
Author

Yes I have checked it/
The problem is with the query generated through Talend. With the use of this addional column, query generated for the insert is
INSERT INTO table_name (col1, col2) values(col1, LEFT(col2,2)).
Basically, Talend is taking literally whatever written between "" (double quotes) in SQL Expression field. Rather it should replace the col2 with a proper value.
Please let me know what query talend generates. You may check the MySQL logs to see the insert query.
Thanks again for your reply.
Anonymous
Not applicable
Author

Sorry, I don't have logs configured with mysql.
Have you tried by enabled the batchsize checkbox?.
Vaibhav