Four Stars

How to pass multiple parameter to a MYSQL table

Hi,

 

I am new to the talend.
I want load the parameter dynamically into the table.

Query:

SELECT
distinct b.bbcode1,
(SELECT NET_SALES FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-18' and bbcode1='Ashok Leyland') AS Revenue_Rs_m1,
(SELECT GROWTH FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-18' and bbcode1='Ashok Leyland') AS 'Revenue_Rs_m YOY1%',
(SELECT ADJ_NET_PRFT FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-18' and bbcode1='Ashok Leyland') AS Adjusted_PAT_Rs_m1,
(SELECT GROWTH_1 FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-18' and bbcode1='Ashok Leyland') AS 'Adjusted_PAT_Rs_m_YOY1%',
(SELECT NET_SALES FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-19' and bbcode1='Ashok Leyland') AS Revenue_Rs_m2,
(SELECT GROWTH FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-19' and bbcode1='Ashok Leyland') AS 'Revenue_Rs_m YOY2%',
(SELECT ADJ_NET_PRFT FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-19' and bbcode1='Ashok Leyland') AS Adjusted_PAT_Rs_m2,
(SELECT GROWTH_1 FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-19' and bbcode1='Ashok Leyland') AS 'Adjusted_PAT_Rs_m_YOY2%',
(SELECT NET_SALES FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-20' and bbcode1='Ashok Leyland') AS Revenue_Rs_m3,
(SELECT GROWTH FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-20' and bbcode1='Ashok Leyland') AS 'Revenue_Rs_m YOY3%',
(SELECT ADJ_NET_PRFT FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-20' and bbcode1='Ashok Leyland') AS Adjusted_PAT_Rs_m3,
(SELECT GROWTH_1 FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-20' and bbcode1='Ashok Leyland') AS 'Adjusted_PAT_Rs_m_YOY3%',
(SELECT RT_ADJ_EPS_RS FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-18' and bbcode1='Ashok Leyland') AS FY_1,
(SELECT RT_ADJ_EPS_RS FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-19' and bbcode1='Ashok Leyland') AS FY_2,
(SELECT RT_ADJ_EPS_RS FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-20' and bbcode1='Ashok Leyland') AS FY_3,
(SELECT CAST((price/FY_1) as decimal(10,1)) FY18_X FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-18' and bbcode1='Ashok Leyland') AS FY_1,
(SELECT CAST((price/FY_2) as decimal(10,1)) FY19_X FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-19' and bbcode1='Ashok Leyland') AS FY_2,
(SELECT CAST((price/FY_3) as decimal(10,1)) FY20_X FROM svg_test.sch6_back_page WHERE PERIOD_END = 'Mar-20' and bbcode1='Ashok Leyland') AS FY_3

FROM svg_test.sch6_back_page b where b.bbcode1='Ashok Leyland';


so i want to like, if i pass a parameter from a file.

par1=Mar-18
par2=Mar-19
par3=Mar-20
bb=Eicher motors

Similarly i have 100 companies names and i have to load one by one to the table dynamically

how to do this in talend. Kindly help me in this how to acheive it step by step.

1 REPLY
Thirteen Stars TRF
Thirteen Stars

Re: How to pass multiple parameter to a MYSQL table

Hi,

SQL queries are just strings so you can have parameters in global or context variables and use them to construct the query dynamically like in this example:

"SELECT col1, col2 FROM myTable WHERE col3 = '" + (String)globalMap.get("param1") + "' AND col4 = " + context.param2

where "col3" is a string column and "col4" is a numeric one.

It's your job to transpose this example to your usecase.


TRF