Kbase P116568: How to pass an OUTPUT Temp-table handle mapped to a java.sql.ResultSet using the Open Client Java Op
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  7/5/2006 |
|
Status: Unverified
GOAL:
How to pass an OUTPUT Temp-table handle using the Open Client Java OpenAPI
GOAL:
How to define a ParamArray variable containing an OUTPUT Temp-Table handle mapped to a java.sql.ResultSet from a Java Open client
FACT(s) (Environment):
OpenEdge 10.1x
FIX:
When defining the ParamArray variable for the parameters, the addTableHandle method has to be called in order to add an OUTPUT Temp-Table.
public void addTableHandle
(int position,
java.sql.ResultSet value,
int mode,
com.progress.open4gl.ProResultSetMetaDataImpl metadata)
throws Open4GLExeption
int position: Specifies a 0-based index indicating the parameter position
java.sql.ResultSet value: Specifies the Java data type of a Temp-Table. Since this is an OUTPUT parameter, this should be null.
int mode: Specifies the 4GL mode (passing direction) of the parameter. For OUTPUT parameter, this should be: ParramArrayMode.OUTPUT
com.progress.open4gl.ProResultSetMetaDataImpl metadata: Provides the schema information for temp-table parameters.
Java Sample code:
In the following sample code, the TToutDynAPI.p procedure returns a Temp-Table handle (OUTPUT TABLE-HANDLE parameter).
import com.progress.open4gl.javaproxy.*;
import com.progress.open4gl.Parameter;
import com.progress.open4gl.*;
public class dynAPI
{
public static void main(String[] args)
{
try
{
// Connect to the AppServer
Connection myConn = new Connection("","","");
OpenAppObject ao = new OpenAppObject(myConn,"asbroker1");
// Create ParamArray variable for parameters
ParamArray params = new ParamArray(1);
// Set up the meta data
ProResultSetMetaDataImpl proMetaData = new ProResultSetMetaDataImpl(0) ;
// Add Temp-Table handle to the ParamArray
params.addTableHandle(0, null,ParamArrayMode.OUTPUT,proMetaData );
// Run the procedure
ao.runProc("TToutOpenApi.p",params);
java.sql.ResultSet rs = (java.sql.ResultSet) params.getOutputParameter(0);
// Display the first field of the temp-table
while(rs.next())
{
System.out.println(rs.getObject(1));
}
ao._release();
}
catch (Exception e){ e.printStackTrace();}
}
}