Progress
Open Client
Developer’s Guide
Passing a TEMP-TABLE Or TABLE-HANDLE As an Output Parameter
In order to get back TEMP-TABLE data from an AppServer, you must create a
ProTempTable
object and pass it as a parameter, without needing to set theDataSource
property. On return, you can call methods on theProTempTable
object directly to retrieve the data.If the parameter is a TABLE-HANDLE, the value returned can be unknown or undefined. As a result, calling
Move Next()
orFields()
onCProTempTable
results in an error and the application must be able to handle this situation.The interface that
ProTempTable
implements is similar to the ADO and DAO interfaces. The interface has methods to get both the data and the metadata of the TEMP-TABLE. For this process, the following objects are used:CProTempTable Object
The
CProTempTable
object provides the following methods and properties for getting output data:
Closes the Recordset (used for output parameters only). Invoke this method if you want to close the Recordset before reading all of the rows.
NOTE: Until you read all rows or invoke this method for the output Recordset, you can call no other Open Client proxy method. For more information, see the sections on streaming in Programming Concepts."
Returns a
Variant
that contains aVariant Array
with oneVariant
for each field of the current row. Only one row can be returned at a time. If the TEMP-TABLE contains an array field, it is flattened such that each element is returned as anotherVariant
in the array. You can only call this method once for each row. Unlike the similar DAO or ADO method, after the data is returned, the Recordset cursor is not automatically moved to the next row, and you must callMoveNext()
to move to the next row.
Changes the current record to the next row of the TEMP-TABLE. If
MoveNext()
has not been called before, it assumes we are at the beginning of the set andMoveNext()
moves to the first record. It returns false when there are no more rows.NOTE: If the parameter is a TABLE-HANDLE, the value returned can be unknown or undefined. In this case, callingMoveNext()
returns an error.
A collection object that holds a set of
CField
objects, where eachCField
object provides access to the data and metadata of a field in the TEMP-TABLE. This property is read-only.
For an input TEMP-TABLE parameter, a property that you can set to an ADO, DAO, or
IClientTempTable
object from which a proxy can obtain the data. For an output TEMP-TABLE parameter, this property is ignored.CFields Object
The
CFields
object provides the following methods and properties:
Returns a
CField
object for the specified field. Theindex
parameter can either be a number or a string. If it is a number, it represents the 1-based field index which must correctly map to the order in which the fields are defined in the 4GL TEMP-TABLE. Otherwise, it must be the field’s name.This method uses the Progress array model to access result set columns. For more information on the array model and flat model, see Programming Concepts."
If you specify the name for an array field, specify the simple name without any array element reference. For example, specify
Months
, notMonths[1]
.This is the default method for the object.
The number of fields in the TEMP-TABLE (including array fields). Each array field counts as one because it is based on the Progress array model.
CField Object
The
CField
object provides the following methods and properties:
The value of the field returned as a
Variant
. If the field is a scalar value,index
can be 0, 1 or left out. If the field is an array,index
is a 1-based index into the array.Depending on your version of Visual Basic, if you access
Value()
indirectly without first setting aCField
object, you must provide a value forindex
. Otherwise, as in this example (whereproTT
is aCProTempTable
object), VB returns a run-time error indicating that there are an invalid number of parameters:
However, the following example executes without error in VB:
You can also access
Value()
directly on aCField
object with or without an index in VB, again without error:
You can invoke this method only once on the same
CField
object, and you must obtain each field value in order. For more information, see the section on output result sets in Programming Concepts." This is the default method for the object.NOTE: The limitation allowing you to callValue()
only once per field might cause errors when debugging your VB application. For example, if you hold your mouse cursor over the call to theValue()
method in order to display the value, in tooltip fashion, this causes an error if the code has already been executed. In a similar manner, an error results if you enterfield.Value()
in the watch window twice.
The name of the field.
Data type of the field. A set of constants accessible from VB are defined as part of
ProTempTableLib
calledProDataTypeConstants
. Table 7–5 lists the constants and their values.
The field’s extent. This returns 0 for non-array fields.
Output TEMP-TABLE Parameter Example for ActiveX
Example 7–4 shows how a VB client can retrieve the first two records of direct deposit information for a particular account.
Example 7–4: ActiveX TEMP-TABLE Output Parameter Using ProTempTable
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |