Skip to content
Advertisement

How to get column names from a query?

I have a specific query with joins and aliases, and I need to retrieve columns name for a REST request in Talend.

I’m using Talend Open Studio for Data Integration 6.2 and I’ve got an Oracle 11g database with a read-only account. I can execute scripts with Talend, For example the query:

should give the following result:

And I try to get the columns (in the right order) as follows by using scripts or Talend:

Is there a way to query the Oracle database to get the columns or using talend to retrieve them?

UPDATE

Thanks to Marmite Bomber, a duplicate has been identified here for the Oracle approach. Now we need a Talend approach to the problem.

Advertisement

Answer

You can try this on a tJavaRow, following your DBInput component :

Spotted on talend help center here : https://community.talend.com/t5/Design-and-Development/resolved-how-to-get-the-column-names-in-a-data-flow/td-p/99172

You can extend this, and put the column list on your outputflow :

With a tNormalize after tJavaRow, you shoud get the expected result.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement