Typically, a step would print each row one at a time as the code iterates over the result set.
If you would like to print the occurrences once rather than print a line for each occurrence, then I would suggest that you consider looping over the resultset, storing each value in a hold area, and printing the results after all the rows have been iterated.
Let us know if this is helpful or if your requirements are different.
For example the basic steps might look like this:
Build Hold Area - JSR 223 step
This step, simply creates some type of hold area for the results. For example, let's say we want to create a property that has a header row separated by a tab character.
import java.lang.StringBuilder;
StringBuilder sb = new StringBuilder();
sb.append("col1\tcol2\r\n");
// Save the hold area to support the loop
testExec.setStateObject( "fl_holdArea", sb );
The read state info is a Read Rows from JDBC Table dataset where you submit your query and iterate. colValue is a property coming from whatever you input source data is:
The Build State Information step is a JSR 223 that takes each row from the result set and appends it to the hold area. The dataset will control the loop so that only the number of occurs in the result set will be iterated.
import java.lang.StringBuilder;
// Get the hold area created in the first step
StringBuilder sb = testExec.getStateObject( "fl_holdArea" );
// Get the Column(s) returned in the query by asking testExec to
// give them back then append them to hold area
sb.append( testExec.getStateValue( "COL1") ).append("\t");
sb.append( testExec.getStateValue( "COL2" ) ).append("\r\n");
// Save the hold area off for the next loop over the result set
testExec.setStateObject( "fl_holdArea", sb );
return true;
Thie Build State Info step loops onto itself so that each of the results from your query is returned. Change the <COLx>, "COL1", "COL2" and <yourTableName> tags in the query and in the script code based on your requirements to the real column names (case sensitivity applies).
At end of the result set, the step branches to the Print Once step which accesses the {{fl_holdArea}} and sends the output to String.