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: 
Anonymous
Not applicable

How to make column names dynamic in tJavaFlex

Hi

 

I have used tOracle input to extract data from Oracle DB.Then used tJavaFlex to split the data into multiple chunks of bytes.

Used the following code in Start and Main code.I have used the option Dynamic in Edit schema of the tJava Fex to get the column lists of the tables on the fly automatically

 

Start Code

 

Integer iterator = 1;
Integer ByteCount = 0;
FileOutputStream fos = new
FileOutputStream(context.TgtFilePath+"TargetFile_"+iterator+".csv");

 

Main Code

 

String tmpReadLine= row1.FirstName+","+
row1.LastName+","+
row1.Age+","+
row1.City+","+
row1.State+"\n"; //Read input fields

byte[] contentInBytes = tmpReadLine.getBytes();//Convert them to Byte array

ByteCount=ByteCount+contentInBytes.length; // Summation of line bytes read

if ( ByteCount > context.SplitByte ) {
// Check if bytes read hasn't crossed the threshold
ByteCount = 0;

fos.flush();
fos.close();
iterator = iterator+ 1;

// Threshold crossed write to new file
fos = new
FileOutputStream(context.TgtFilePath+"TargetFile_"+iterator+".csv");
} else {
fos.write(contentInBytes); // else write to same file
}

 

Now I do not want to hard-code the column names in the Main code portion of the tJavaFlex(as given in bold above).

What is the alternative solution to make the column names dynamic because I want to use the same Talend job for multiple data extraction

Labels (3)
0 Replies