Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - Programming » Java in the database » Special features of Java classes in the database

 

How to return result sets from Java methods

Write a Java method that returns a result set to the calling environment, and wrap this method in a SQL stored procedure declared to be EXTERNAL NAME of LANGUAGE JAVA.

Perform the following tasks to return result sets from a Java method:

  1. Ensure that the Java method is declared as public and static in a public class.

  2. For each result set you expect the method to return, ensure that the method has a parameter of type java.sql.ResultSet[]. These result set parameters must all occur at the end of the parameter list.

  3. In the method, first create an instance of java.sql.ResultSet and then assign it to one of the ResultSet[] parameters.

  4. Create a SQL stored procedure of type EXTERNAL NAME LANGUAGE JAVA. This type of procedure is a wrapper around a Java method. You can use a cursor on the SQL procedure result set in the same way as any other procedure that returns result sets.

    For more information about the syntax for stored procedures that are wrappers for Java methods, see CREATE PROCEDURE statement [External call].

 Example
 See also