Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
JMartin1
Contributor
Contributor

How to truncate a string in a tjavarow

Hello! I have a problem when inserting a dynamic file into an oracle table, there are fields in the file of length greater than 4000, I am trying to shorten the string to the length that allows me to insert in the table(Drop create)

Labels (3)
3 Replies
Anonymous
Not applicable

You can use the standard Java String methods to achieve this or write your own routine (essentially a Java class) to do this if you need to apply complicated rules to decide upon how to truncate the Strings.

JMartin1
Contributor
Contributor
Author

Hi!, samething like this:

 

Dynamic dyn = row1.InputRow;

 

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

DynamicMetadata meta = dyn.getColumnMetadata(i);

 

//  System.out.println(meta.getName()+ "; " + StringHandling.SUBSTR(dyn.getColumnValue(i).toString(), 1, 10));

  dyn.setColumnValue(i, StringHandling.SUBSTR(dyn.getColumnValue(i).toString(), 1, 4000));

  meta.setLength(4000);

}

row2.InputRow = dyn;

 

Anonymous
Not applicable

A while ago I wrote a blog on doing something similar to this. I have just hunted it out as it is no longer available on our blog page here. You can see it here....

 

https://web.archive.org/web/20200919070520/https://www.talend.com/blog/2019/11/11/migrate-data-between-databases-one-job-using-dynamic-schema/

 

The code should be a good pointer about how to get access to the columns in a dynamic schema.