Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have a tJavaRow with some input and output rows
I have a random column name and I want to set that output column as null
How can I do that ?
Thank all.
What you could try will take a fair amount of work, will perform a little slower, but will not require quite as much coding as my previous suggestion. You could try connecting your data source to a tFlowToIterate. This will iterate over the dataset once row at a time. However, what it does is load each row into the globalMap HashMap. The "key" to the value can either be the default {row}.{column} String or something you specify for each column. After your tFlowToIterate, connect to a tJavaFlex. In the "Start Code" section you could write something to iterate over the globalMap using your String variable to find the columns that should be null and change them. Then in the "Main Code" section you can simply have code to map the corresponding globalMap value with the correct output column. Your dynamic functionality would be in the Start Code section and what you have in the Main Code (albeit a lot of lines of code) would be fixed.
It will be null unless you set it to something else
If you want the column set to null for every row, just don't set a value. For example, if your input and out columns are set as below....
output_row.newColumn = input_row.newColumn; output_row.newColumn1 = input_row.newColumn1; output_row.newColumn2 = input_row.newColumn2; output_row.newColumn3 = input_row.newColumn3;
....and you want to ensure that "newColumn2" is null, you can either....
output_row.newColumn = input_row.newColumn; output_row.newColumn1 = input_row.newColumn1; output_row.newColumn3 = input_row.newColumn3;
... or....
output_row.newColumn = input_row.newColumn; output_row.newColumn1 = input_row.newColumn1; output_row.newColumn2 = null; output_row.newColumn3 = input_row.newColumn3;
So something more dynamic? You could try something like this...
if(myStringVar.equals("newColumn")){
output_row.newColumn = null;
output_row.newColumn1 = input_row.newColumn1;
output_row.newColumn2 = input_row.newColumn2;
output_row.newColumn3 = input_row.newColumn3;
}else if(myStringVar.equals("newColumn1")){
output_row.newColumn = input_row.newColumn;
output_row.newColumn1 = null;
output_row.newColumn2 = input_row.newColumn2;
output_row.newColumn3 = input_row.newColumn3;
} //..... etc
OK, lets go back a few steps. Why do you need to do this? What is the requirement? I'm sure your requirement can be met, but I will need to know all of the information before I can suggest something sensible
What you could try will take a fair amount of work, will perform a little slower, but will not require quite as much coding as my previous suggestion. You could try connecting your data source to a tFlowToIterate. This will iterate over the dataset once row at a time. However, what it does is load each row into the globalMap HashMap. The "key" to the value can either be the default {row}.{column} String or something you specify for each column. After your tFlowToIterate, connect to a tJavaFlex. In the "Start Code" section you could write something to iterate over the globalMap using your String variable to find the columns that should be null and change them. Then in the "Main Code" section you can simply have code to map the corresponding globalMap value with the correct output column. Your dynamic functionality would be in the Start Code section and what you have in the Main Code (albeit a lot of lines of code) would be fixed.