Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
prasanthkesana
Contributor
Contributor

How to insert/update data into db2 table based on different conditions and different columns in a db2 table

Hi All,

I need help to insert data into db2 table based on different conditions need to update / insert different columns in a same table.

for example

If (column1 == 1)

{

then insert/update into db2 table1 columns (column1, column2, column3)

}

else if (column1 == 2 )

{

then insert/update into db2 table1 columns (column4, column5, column6)

}

else if (column == 3)

{

then insert/update into db2 table1 columns are (column7,column8, column9)

}

On update where condition need to fetech data from table,

for example

UPDATE table1

   SET

    column1

    column2 

    column3

   WHERE

    column0         = (SELECT MAX(date) FROM table1  

               WHERE column0 = 1)

Please suggest to create a talend job to cover the above scenarios.

Thanks,

Prasanth

Labels (2)
6 Replies
shalinim1
Contributor III
Contributor III

Hi @prasanth kesana​,

 

You can get your requirement done by using tmap.

 

The flow of job should be like,

 

tdbinput--> tmap--> 3*tdboutput

 

Write your condition for each insert/update (ex-row1.column1 == 1) in expression tab on tmap. And map the corresponding input columns to output table columns.

 

Hope this will help you.

 

Regards,

Shalini

 

manodwhb
Champion II
Champion II

@Shalini M​ ,you need to use tMap component to do your requirements.

 

Thanks,

Manohar

 

 

prasanthkesana
Contributor
Contributor
Author

Hi Shalini,

 

Thank you.

please suggest on update statement in where condition need to fetch data from db2 table.

 

Regards,

Prasanth

shalinim1
Contributor III
Contributor III

@prasanth kesana​, Could you please elaborate your requirement?

prasanthkesana
Contributor
Contributor
Author

@Shalini M​ , I need to update table like this query using talend job.

for example-

 

UPDATE table1

   SET

    column1

    column2 

    column3

   WHERE

    column0         = (SELECT MAX(date) FROM table1  

               WHERE column0 = 1)

 

Thanks,

Prasanth

shalinim1
Contributor III
Contributor III

@prasanth kesana​, please try column0 equals 1 in tmap input flow and load to output as I mentioned in above reply.