Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
rmcclure
Contributor III
Contributor III

Convert Dynamic to String

I have a requirement to run a series of 49 SQL statements and collect the results.

These SQL statements are stored in a Snowflake table. I need to read the table get each of the 49 SQL statements, execute each of them and collect the results of each into another table. 

One issue is that the 49 statements return 49 different sets of results (ex: number of fields and field type). I found I can run and display the results with output column of type Dynamic. The target table has a type of String so I need to convert the dynamic field to one big string instead of extracting the individual fields.

I tired using a tExtractDynamicFields with a string as the output but it comes out NULL.

Labels (2)
3 Replies
Anonymous
Not applicable

Hi

You need to get the schema properties and

concatenate all fields into one string on a tJavaRow,/tJavaFlex, please look at this blog to learn how to get the schema properties at runtime.

 

Regards

Shong

gjeremy1617088143

hi you could do something like this in a tJavaRow with input_row Dynamic and output_row String :

 

Dynamic columns = input_row.newColumn;

String str ="";

for (int i = 0; i < columns.getColumnCount(); i++) { 

     DynamicMetadata columnMetadata = columns.getColumnMetadata(i); 

     str += columns.getColumnValue(i);

}

output_row.newColumn = str;

archienesss
Contributor
Contributor

Hello Shong,

 

Thanks for your reply! But I am hoping this blog post you shared can be made available again. I really think this is exactly what I am looking for. Thanks again!