1.0

Table Of Contents
For example:
OutgoingResultSet rs1 = context.getOutgoingResultSet(1);
rs1.addColumn("field1");
rs1.addColumn("field2");
for (int i = 0; i < 10; i++) {
rs1.addRow(new Object[i, String.valueOf(i)]);
}
rs1.endResults();
Note: Do not close the connection or the statement that you use to create the result set, because doing so
also closes the result set.
Using the <local> and <global> Escape Syntax with Nested Queries
A query that is nested within a data-aware procedure may be executed on local member data, or it may be
re-distributed to the SQLFire cluster and executed on multiple SQLFire members. The <local> and <global>
escape syntax can be used to override the default behavior for nested queries.
If a data-aware procedure is invoked without specifying a WHERE clause in the CALL statement, then by default
SQLFire treats a nested query in the procedure implementation as a "global" query. This means that the nested
query is distributed to the SQLFire cluster and accesses table data from all SQLFire members that host data for
the table. Note that global queries can return duplicate results with a single procedure call, because each member
that executes the procedure body invokes a separate global query.
If a procedure is invoked using a WHERE clause, then by default SQLFire treats the nested query in the procedure
implementation as a "local" query. This means that the query only accesses the local partitioned table data that
is assigned to the procedure on the SQLFire member where the procedure executes.
You can override this default behavior by specifying either the "<local>" or "<global>" escape syntax at the
very beginning of a nested query string in your procedure implementation.
For example, the following nested queries always operate with local table data, even you invoke the procedure
without specifying a WHERE clause:
Connection cxn = context.getConnection();
Statement stmt = cxn.createStatement();
resultSet1[0] = stmt.executeQuery("<local> select * from Bar where foo >
42");
resultSet2[0] = stmt.executeQuery("<local> select * from Bar where foo <=
42");
Note: When you use the ON TABLE clause to invoke a procedure, any <local> queries within the
procedure body target only the primary data for a partitioned table on the local node. For replicated tables,
a local query accesses only a single replica. In both cases, this avoids returning duplicate values in the
procedure.
When you use ON ALL to invoke a procedure, <local> queries execute only the local member for
partitioned table data. However, <local> queries against replicated tables return duplicate results.
vFabric SQLFire User's Guide152
Developing Applications with SQLFire