Five Stars ami
Five Stars

SQL query output and passing a default value to the output

Dear's,

 

I have a requirement , in which i have a sql query  and i need to classified the output to default value ex:-TEST

The sql query has one column and it  will fetch me 100 rows with different  id's

Now once i get the output i need to pass a default value 'TEST' to that column

 query  is : select * from table where id<=5 , i need to pass this query and generate output as below

ex: if the query gives me 5 rows , With different values like below

 

ID

1

2

3

4

5

 

My output should be 

ID

TEST

TEST

TEST

TEST

TEST

 

Basically i need to classify  using the query .

how shall i do it using talend?

 

Please help will be appreciated.

 

5 REPLIES
Employee

Re: SQL query output and passing a default value to the output

Hi Ami,

 

It sounds like you want to mask your data. You have two ways:

 

1. Your mapping. A tMap will typically map the input_row.id --> out_row.id. Your mapping expression can be a constant. So out_row_id can be simply mapped to a constant "TEST".

2. You can also explore the Data Masking features available in Talend, very flexible and versatile. Watch this video for a quick demo:

 

https://www.youtube.com/watch?v=YTl8IgaoZv8

 

If you want your value to be a parameter, check how to use Context variables here:

 

https://help.talend.com/display/TalendOpenStudioforESBUserGuide60EN/3.4.1+How+to+define+context+vari...

 

HTH

Gene

 

Twelve Stars TRF
Twelve Stars

Re: SQL query output and passing a default value to the output

Just try to replace your query by this one:

select 'TEST' as ID from table where id<=5

 

Regards

TRF


TRF
Five Stars ami
Five Stars

Re: SQL query output and passing a default value to the output

Thanks , was thinking on similar lines , we will try this and intimate you bro!
Five Stars ami
Five Stars

Re: SQL query output and passing a default value to the output

Thanks for the reply surely i will try out this
Five Stars ami
Five Stars

Re: SQL query output and passing a default value to the output

Dear,

I want to implement this as a incremental job ,
i want to incrementally pull data from the below query

to Take the unique ID from schema_name.table_name where ID like ‘11%’

I have never used incremental in talend .
Can you give me steps to build one job ?
Many Thanks,
Amit