One Star

[resolved] Constants and SQL expressions in t_Map

How can I pass a constant in T_map component. I have to map 30 columns in source table and 40 columns in destination table. I map 10 columns directly, for some I have to perform expressions such as CASE WHEN column_name <> '' THEN column_name ELSE NULL, and sometimes I have to put in a constant sting or integer like '100' or 'test_value'. How can I achieve that?
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] Constants and SQL expressions in t_Map

Hi
Convert String or varchar to Integer: Integer.parseInt("123")
Convert Integer/int to String: String.valueOf(123)
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
8 REPLIES
Community Manager

Re: [resolved] Constants and SQL expressions in t_Map

Hi
You can set the constants expression on tMap like this: condition?the value if true:the value if false, for example:
row1.columnName.equals("")?NULL:row1.columnName
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Constants and SQL expressions in t_Map

Great thank you for the answer but what if I wanted to put in a string value into column using tMap without using expression? eg. 'text'
Community Manager

Re: [resolved] Constants and SQL expressions in t_Map

Hi
Yes, you can type in a fixed string value in the expression field, eg: "text"
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Constants and SQL expressions in t_Map

And one last thing how on earth can I convert string or varchar into integer before mapping? I have to map varchar column to column that is of type string
Community Manager

Re: [resolved] Constants and SQL expressions in t_Map

Hi
Convert String or varchar to Integer: Integer.parseInt("123")
Convert Integer/int to String: String.valueOf(123)
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Constants and SQL expressions in t_Map

Thank you very much for Your help. I know that these question may seem stupid but I naver used this component thouh it's one of the most basic ones.
Regards
Bro
One Star

Re: [resolved] Constants and SQL expressions in t_Map

I have mapped two tables connected to each other with fk. The situation looks like this:
Employee_id of table employees has been generated from sequence on insert
Employee_id in salary table has to be filled in from Employees table joined on personal insurance number mapped from csv input.
Both mappings are done in one job Employees have insert order 1 and salary has order 2 how can I map the employees_id ? Do I need to add anothe PostgreSQL_input or can it be done inside tMap by usin "SELECT employee_id from employees emp where emp.insur_no = row1.columnName"?
Community Manager

Re: [resolved] Constants and SQL expressions in t_Map

I have mapped two tables connected to each other with fk. The situation looks like this:
Employee_id of table employees has been generated from sequence on insert
Employee_id in salary table has to be filled in from Employees table joined on personal insurance number mapped from csv input.
Both mappings are done in one job Employees have insert order 1 and salary has order 2 how can I map the employees_id ? Do I need to add anothe PostgreSQL_input or can it be done inside tMap by usin "SELECT employee_id from employees emp where emp.insur_no = row1.columnName"?

Hi
For better management, one topic for one question, please report a new topic for your new question with details.
Thanks for your support!
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business