1.1

Table Of Contents
The MergeSort processor is designed for use with a single procedure implementation that returns only a single
result set and no OUT parameters. The procedure implementation is shown in Procedure Implementation on
page 164, and the procedure would be congured in SQLFire using a statement similar to the following.
CREATE PROCEDURE MergeSort ()
LANGUAGE JAVA
PARAMETER STYLE JAVA
READS SQL DATA
DYNAMIC RESULT SETS 1
EXTERNAL NAME 'examples.MergeSortProcedure.mergeSort'
Your own result processor implementations may need to work with the output from multiple procedures, and
take into account the possibility of multiple result sets and OUT parameters accordingly.
Procedure Implementation
The example result processor supports this procedure implementation. The procedure uses a single result set and
no OUT parameters.
package examples;
import com.vmware.sqlfire.*;
import java.sql.*;
public class MergeSortProcedure {
static final String LOCAL = "<local>";
public static void mergeSort(ResultSet[] outResults,
ProcedureExecutionContext context)
throws SQLException {
String queryString = LOCAL
+ "SELECT * FROM "
+ context.getTableName();
Connection cxn = context.getConnection();
Statement stmt = cxn.createStatement();
ResultSet rs = stmt.executeQuery(queryString);
outResults[0] = rs;
// Do not close the connection since this would also
// close the result set.
}
}
Merge Sort Result Processor
This result processor implementation sorts the results from the MergeSortProcedure, which returns a single result
set.
package examples;
import com.vmware.sqlfire.*;
import java.sql.*;
import java.util.*;
public class MergeSortProcessor implements ProcedureResultProcessor {
private ProcedureProcessorContext context;
public void init(ProcedureProcessorContext context) {
this.context = context;
vFabric SQLFire User's Guide164
Developing Applications with SQLFire