Add a filter in tOracleInput query

Four Stars

Add a filter in tOracleInput query

Hi everyone, I want to ask you how to add a filter in tOracleInput query. Example : " select * from table1 where name='blabla'" So how to add the syntax "where name='blabla' dynamically ? Thanks for your responses.

Accepted Solutions
Nine Stars

Re: Add a filter in tOracleInput query

The Sql queries in Talend are simply String represented in Java language format. So, to play with them you and build your query dynamically you have to make sure you built a String which will finally represent a legitimate SQL query.

Example : 

"select * from table1 where name='blabla'"

Now if you want to have your WHERE clause to be dynamic and make it pass from context variable you could simply use - 

"Select * from table1 " + context.whereclause

or if you want to get it from any previous component values

"Select * from table1 " + ((String)globalMap.get("row1.whereclause"))

Tip: Build your SQL query, output it to the console and then test the String you see in your database. If it works there, it will work in your Talend component.


All Replies
Nine Stars

Re: Add a filter in tOracleInput query

The Sql queries in Talend are simply String represented in Java language format. So, to play with them you and build your query dynamically you have to make sure you built a String which will finally represent a legitimate SQL query.

Example : 

"select * from table1 where name='blabla'"

Now if you want to have your WHERE clause to be dynamic and make it pass from context variable you could simply use - 

"Select * from table1 " + context.whereclause

or if you want to get it from any previous component values

"Select * from table1 " + ((String)globalMap.get("row1.whereclause"))

Tip: Build your SQL query, output it to the console and then test the String you see in your database. If it works there, it will work in your Talend component.

Twelve Stars

Re: Add a filter in tOracleInput query

use context or globalMap variables to store blabla
the use java syntax ("select * from table where name=''" + globalMap.get("blablaVariableName")+ "") to write yours query.
regards

Francois Denis

Tag as "solved" for others! Kudos to thanks!

Four Stars

Re: Add a filter in tOracleInput query

Thank you guys.

Twelve Stars

Re: Add a filter in tOracleInput query

hi,

One day you are going to help me or someone!

you can use kudos to thank.
you can Tag "solved" to help on same problems.

Regards,

Francois Denis

Tag as "solved" for others! Kudos to thanks!

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch