Progress
Open Client
Developer’s Guide
Providing Metadata For INPUT TABLE-HANDLE Parameters
For TEMP-TABLE parameters, the proxy calls the
next()
andgetObject()
methods to get the data that needs to be passed to the AppServer methods. For a TABLE-HANDLE parameter, the proxy must first call thegetMetaData()
method to determine the format of the data. There are several alternatives for howgetMetaData()
can supply the appropriateResultSetMetaData
object:
- Use a Standard JDBC ResultSet under the following conditions:
- If the input ResultSet is a standard JDBC ResultSet obtained from a query, the client application does not need to do anything. The
ResultSet
instance already implements thegetMetaData()
method and returns a standardResultSetMetaData
object.The proxy automatically maps SQL data types to Progress data types as shown in Table 5–5.
NOTE: Because a standardResultSet
supports a standardResultSetMetaData
object and not the Progress extension (ProResultSetMetaData
), there can be no array fields.
Table 5–5: Mapping Between SQL and Progress Data Types For Standard JDBC ResultSet Progress 4GL Type SQL Type INTEGER DECIMAL CHARACTER LOGICAL DATE RAWIf the ResultSet contains any other type, an Exception is throw.
- If the
ResultSet
contains a column type other than the types shown in Table 5–5 and the column can be converted to a compliant type, implement your ownResultSet
class instead of passing thejava.sql.ResultSet
directly as the parameter. For example, you can extendcom.progress.open4gl.InputResultSet
with your own class.When
getObject()
is called on your class, it retrieves data from the corresponding standard object and converts the data before returning it to the proxy. When thegetMetaData()
method is called, the implementation of your extended class must supply the appropriate metadata. To do this, the application must create and populate aProResultSetMetaDataImpl
object as described in the section under the Use ProResultSetMetaDataImpl bullet.If the application requires the resulting server-side TEMP–TABLE to have an array field, this is another reason for you to implement a delegating
InputResultSet
class. This time, the implementation of bothnext()
andgetObject()
call the standard instance’s corresponding methods to do the work. However, when thegetMetaData()
method is called, the delegating instance must supply the required metadata, with the flattened schema view converted to the corresponding array field view. Again, to do this, the application must create and populate aProResultSetMetaDataImpl
object as described in the section under the Use ProResultSetMetaDataImpl bullet.- Use the
ResultSetMetaData
from a previously obtained OUTPUT ResultSet under the following condition:
- If the input
ResultSet
is aResultSet
that was first obtained from the AppServer through an OUTPUT parameter, metadata can be obtained from that output set by callinggetMetaData()
on it. You can think of this as an INPUT–OUTPUT TABLE-HANDLE parameter even though it is output from one method call and input through another. TheResultSet
object obtained from the outputResultSet
can then be provided whengetMetaData()
is called for the inputResultSet
.- Use ProResultSetMetaDataImpl under the following condition:
If the metadata for the input
ResultSet
must be supplied by code implemented in the client application, thegetMetaData()
method must be implemented to return an instance ofResultSetMetaData
. The recommended way to do this is to use thecom.progress.open4gl.ProResultSetMetaDataImpl
class provided in the Open Client Toolkit. This is an implementation of theProResultSetMetaData
interface, the same interface that is used by the client when getting output data.The only two methods of
ProResultSetMetaDataImpl
that the application must call are the constructor and theSetFieldMetaData()
method as follows:
The
SetFieldMetaData()
method requires the following:
- The fieldNumber parameter must be between 1 and the number of fields
- The Name parameter cannot be null
- The value of the Name parameter must be unique within the table
- The extent must be zero or greater
- The type parameter must be of the PRO_XXX types supplied by
com.progress.open4gl.Parameter
The Open Client Toolkit JavaDoc in Progress-Install-Directory/
java/doc
describes the methods used by the client application for theProResultSetMetaDataImpl
class.To pass a self-implemented result set for a TABLE–HANDLE parameter, the application must:
- Create a new class that extends
com.progress.open4gl.InputResultSet
to provide access to the data to be passed to the server. This object’s implementation includes code fornext()
andgetObject()
(as for a static TEMP–TABLE) and also forgetMetaData()
which should return thecom.progress.open4gl.ProResultSetMetaDataImpl
instance when called.- Create an instance of the class you created in Step a.
- Create an instance of
com.progress.open4gl.ProResultSetMetaDataImpl.
- Call
ProResultSetMetaDataImpl.setFieldMetaData()
for each field of the table- Make the
ProResultSetMetaDataImpl
instance available to theInputResultSet
object. You can do this in any way you like, for example, by adding asetMetaData()
method to yourInputResultSet
implementation.NOTE: Step c and Step d can be implemented in- Make the proxy method call passing the
com.progress.open4gl.InputResultSet
instance as the parametergetMetaData()
which eliminates the need for Step e.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |