[resolved] Copy data from one column to another new column on the same table

One Star

[resolved] Copy data from one column to another new column on the same table

Hi,
I need to copy all the data of a particular table column into a new column within the same table. But when copying data from source column to new column I need to transform the data of the source column (String to Double conversion). How can I achieve thin in Talend Open Studio for Data Integration. I'm using version 5.4.1.
Thanks and Regards,
Asanka.

Accepted Solutions
Four Stars

Re: [resolved] Copy data from one column to another new column on the same table

Hi,
Use following jobs
tDBInput-->tMap-->tDBOutput
For above configuration you need a key column...
in tMap use key column and value of input column assign it to output column, use above transformation for your output column
Set key column in tDBOutput, this will insert the each input data from input column into the new column...
Thanks
Vaibhav

All Replies
One Star

Re: [resolved] Copy data from one column to another new column on the same table

Try this expression
Double.parseDouble(row.newColumn)
Four Stars

Re: [resolved] Copy data from one column to another new column on the same table

Hi,
Use following jobs
tDBInput-->tMap-->tDBOutput
For above configuration you need a key column...
in tMap use key column and value of input column assign it to output column, use above transformation for your output column
Set key column in tDBOutput, this will insert the each input data from input column into the new column...
Thanks
Vaibhav
One Star

Re: [resolved] Copy data from one column to another new column on the same table

Hi sanvaibhav,
Thanks for the replies. 
In my case the table doesn't have a key column. I tried the same steps suggested here before I start this topic. Is there any other ways to copy entire data of a particular column to a new column within the same table where the tables doesn't have a key column? Someone please advice on this.
Thanks and Regards,
Asanka. 
Four Stars

Re: [resolved] Copy data from one column to another new column on the same table

Hi,
That does not matter whether your database has a key or not... in above configuration, set all the columns as key columns in tDBoutput component except newly added column and set update task
Another way could be ...
First read the table and put the contents in tHash component in tPreJob
Use tmap to add new column with required transformation and insert data into the database... may be if possible you can do truncate and load...
Thanks
Vaibhav
One Star

Re: [resolved] Copy data from one column to another new column on the same table

Hi sanvaibhav,
Thank you very much for your reply. I tried your first options suggested in the above post. I set all columns as key columns of the tOracleOutput component (except newly created columns) and selected 'Update' option from Action on data options. But it doesn't copy the data from the old columns to the newly created columns. Have I missed any configurations in my job design?
Thanks and Regards,
Asanka.
Four Stars

Re: [resolved] Copy data from one column to another new column on the same table

Have you set the value of old column to new column? i.e. in tMap output for new column, you set the value as row.oldColumn.
Vaibhav
One Star

Re: [resolved] Copy data from one column to another new column on the same table

Hi Vaibhav,
Yes. I have set the values for the new column of the output. There are some null columns in the selected key column set. Can that be a issue? Cant we specify nullable column as a key in configuration?
Thanks and Regards,
Asanka.
Four Stars

Re: [resolved] Copy data from one column to another new column on the same table

No... null can't be a key column value...
if all the columns are not mandatory you can select one or two which specify unique row and are not nullable
vaibhav
One Star

Re: [resolved] Copy data from one column to another new column on the same table

Hi Viabhav,
Thanks for the information. Your suggestion solved my problem.
Thanks and Regards,
Asanka.