Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
kvinoth19991
Contributor II
Contributor II

[resolved] Creating Dynamic table in TOS

Hi Guys ,

I need to create dynamic table with the use of data from file

For Example :
file1.csv
Sno;ColumnName
1;Name
2;Gender
3;Age
4;Address

By reading the file1.csv - I should dynamically create table with columns - Name , Gender , Age & Address

Thanks in advance

Regards,
Vinoth Kumar K.

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

Hi 
I think you can write a create table statement based on each row on a tJavaFlex, and then execute the statement on a tPostgresqlRow.

tFileinputDelimited--main(row1)--tJavaFlex
   |
onsubjobok
   |
tPostgresqlRow

on tJavaFlex:

In the begin part:
String query="CREATE TABLE tableName (";

in the main part:
//assuming the datatype of all column is varchar, and the length is 10
query=query+row1.columnName+ " varchar(10),";

in the end part:
//remove the last common"," and append ")";
query=query.substring(0,query.lastIndexOf(","))+")";
globalMap.put("query",query);


On tPostgresqlRow:

(String)globalMap.get("query")


Regards
Shong

View solution in original post

6 Replies
kvinoth19991
Contributor II
Contributor II
Author

Guys ,
Any idea on this ?
Please sugguest me someway

Regards,
Vinoth Kumar K. 
Anonymous
Not applicable

What about the other column properties such as data type, length?
kvinoth19991
Contributor II
Contributor II
Author

Thanks for the response shong 0683p000009MACn.png

All the column properties will have same data type and length

Help me to do it.
Regards,
Vinoth Kumar K.
kvinoth19991
Contributor II
Contributor II
Author

Guys ,

Please give me some idea

Thanks & Regards,
Vinoth Kumar K.
Anonymous
Not applicable

Hi 
I think you can write a create table statement based on each row on a tJavaFlex, and then execute the statement on a tPostgresqlRow.

tFileinputDelimited--main(row1)--tJavaFlex
   |
onsubjobok
   |
tPostgresqlRow

on tJavaFlex:

In the begin part:
String query="CREATE TABLE tableName (";

in the main part:
//assuming the datatype of all column is varchar, and the length is 10
query=query+row1.columnName+ " varchar(10),";

in the end part:
//remove the last common"," and append ")";
query=query.substring(0,query.lastIndexOf(","))+")";
globalMap.put("query",query);


On tPostgresqlRow:

(String)globalMap.get("query")


Regards
Shong
kvinoth19991
Contributor II
Contributor II
Author

Thank you so much shong 0683p000009MACn.png  0683p000009MACn.png