Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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)
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.
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;
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.