Here are the calls to construct a result set and send it row-by-row:
Create a JServerResultSetMetaData object by calling JContext.createServerResultSetMetaData().
Call the JServerResultSetMetaData methods to define the format of the result rows, as follows:
JServerResultSetMetaData.setColumnCount(int) to specify the number of columns in each row.
For each column, call JServerResultSetMetaData.setColumnType(int, int) to specify the datatype.
For columns that have a variable length datatype, call JServerResultSetMetaData.setColumnDisplaySize(int, int) to specify the maximum length for column values.
Call other JServerResultSetMetaData methods to specify other column attributes as needed.
Create a JServerResultSet object by calling JContext.createServerResultSet().
Call JServerResultSet.next() to position the result set’s cursor at the first row.
For each row to be sent:
For each column, call the appropriate JServerResultSet.set<Object>(int, <Object>) method to set the column value.
Call JServerResultSet.next() to send the row.
If sending a single result set or if using JDBC types, call JServerResultSet.done() to indicate that all rows have been sent in the current result set.
If your component uses IDL/Java datatypes, use the com.sybase.CORBA.IdlResultSet class to convert the result set to a TabularResults.ResultSet instance. See Chapter 1, “Java Classes and Interfaces,” in the EAServer API Reference for details.
You can repeat steps 4 to 6 to send or create another result set that has the same metadata using the same JServerResultSet object. Repeat steps 1 to 6 to send or create another result set that requires different metadata.
You cannot return multiple result sets unless the method’s IDL definition returns TabularResults::ResultSets.
Copyright © 2005. Sybase Inc. All rights reserved. |