Friday, May 29, 2015

How to Execute multiple SQL queries using tMysqlRow component in Talend !!

In this post I will show you how to execute multiple SQL queries using tMysqlRow component.

Drag and drop the following components from the palette tMysqlConnection , tMysqlRow , tMysqlCommit.

How to do connect each component:--

Right click on tMysqlConnection and select Trigger > OnSubjobOk and drag a line o the tMysqlRow component .
Right click on tMysqlRow and select Trigger > OnSubjobOk and drag a line o the tMysqlCommit component .

Open the component properties of tMysqlConnection .

We have to set the additional JDBC parameters to allow multiple queries to be executed. 
To do this enter "allowMultiQueries=true" in the Additional JDBC parameters text box on the tMySQLConnection component.


Open the component properties of tMysqlRow .
Enter the multiple SQL queries separated by semicolon “;” in the Query text box
In this I have created a table with columns and insert a value in the column.
Don't forget to put " " at the starting of the query and ending of the query.

"Create table MysqlRow_demo
(Emp_ID int,
Emp_FirstName varchar(10),
Emp_LastName varchar(10),
Emp_Address varchar(20),
Emp_City varchar(10),
Emp_Pincode int);

INSERT INTO MysqlRow_demo VALUES(101,'John','Kumar','KR Puram','bangalore',569830);
INSERT INTO MysqlRow_demo VALUES(102,'Bren','Mahlotra','Mallesharam','Gujrat',672395);
INSERT INTO MysqlRow_demo VALUES(103,'Krishna','Tomar','Jayanagar','Pune',492365);"


At last Run the job you will see that table has been created in the database .


No comments:

Post a Comment