One Star

Adding UUID to the database table

I want to transform ms sql database table to postgres through a transformation.
In this transformation, I want to add a new column which contains uuid for the new row to be inserted.
As well as uuid should be generated from the table contents itself.
I can transform the table (without uuid) for now..but unable to generate uuid and map it to the postgres database table.
Can I map it through tMap??
7 REPLIES
Moderator

Re: Adding UUID to the database table

Hi,

Due to there is no "uuid" in your target DB, you should add column of "uuid" first. ("Alter table tablename add Column name type varchar(100)") firstly.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.

Re: Adding UUID to the database table

You can write a routine to generate your UUID and then just call it from tMap.
e.g.
...
import java.util.UUID;
...
public static String getUUID() {
return UUID.randomUUID().toString();
}
...
One Star

Re: Adding UUID to the database table

I added column for storing "uuid" in target table. And I have my own mechanism (breaking 1 column of same table into pieces and re arranging it) to generate through SELECT sql (using queries in repository).
What does that query returns as result set?? How to see that?
I am giving the output of the query to a tMap component. But the result of that query can not be read by tMap. How to resolve this issue?
tMap is forwardly connected to target DB (Postgres).
Moderator

Re: Adding UUID to the database table

Hi,
Result set? Talend provide a component tParseRecordSet which parses a set of records from a database table or DB query and possibly returns single records.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Adding UUID to the database table

@sabrina : I wanted to know, how can I proccess that "uuid" which I have generated in select query. Because I can not see that column name in tMap component while mapping table fields

Re: Adding UUID to the database table

have you added it to the schema of your database input component? if you have, it should be available to tMap.
One Star

Re: Adding UUID to the database table

@talendByExample : yup. I did that. Still its not working. Do you have any other solution??