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 the DataSource property. On return, you can call methods on the ProTempTable 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() or Fields() on CProTempTable 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:

SYNTAX
Close() 

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."

SYNTAX
Variant GetRow() 

Returns a Variant that contains a Variant Array with one Variant 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 another Variant 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 call MoveNext() to move to the next row.

SYNTAX
Boolean MoveNext() 

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 and MoveNext() 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, calling MoveNext() returns an error.

SYNTAX
CFields Fields 

A collection object that holds a set of CField objects, where each CField object provides access to the data and metadata of a field in the TEMP-TABLE. This property is read-only.

SYNTAX
Object DataSource 

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:

SYNTAX
CField Item(Variant index) 

Returns a CField object for the specified field. The index 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, not Months[1].

This is the default method for the object.

SYNTAX
short Count 

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:

SYNTAX
Variant Value( [ integer index ] ) 

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 a CField object, you must provide a value for index. Otherwise, as in this example (where proTT is a CProTempTable object), VB returns a run-time error indicating that there are an invalid number of parameters:

x = proTT.Fields.Item(1).Value 

However, the following example executes without error in VB:

x = proTT.Fields.Item(1).Value(0) 

You can also access Value() directly on a CField object with or without an index in VB, again without error:

set fld = proTT.Fields.Item(1)
x = fld.Value 

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 call Value() only once per field might cause errors when debugging your VB application. For example, if you hold your mouse cursor over the call to the Value() 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 enter field.Value() in the watch window twice.

SYNTAX
String Name 

The name of the field.

SYNTAX
short Type 

Data type of the field. A set of constants accessible from VB are defined as part of ProTempTableLib called ProDataTypeConstants. Table 7–5 lists the constants and their values.

Table 7–5: ActiveX Data Types For TEMP-TABLE Output Parameters 
ProDataTypeConstants
Values
ProChar
1
ProDate
2
ProLogical
3
ProInteger
4
ProDecimal
5
ProRecid
7
ProRaw
8
ProWidgetHandle
10
ProRowid
13
ProComHandle
14

SYNTAX
integer Extent 

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.

Dim objAcct As AccountLib.CAccount
Dim ProTT As ProTempTableLib.CProTempTable
Dim flds As ProTempTableLib.CFields
Dim fld(3) As ProTempTableLib.CField
Dim DirDeposit(2, 3) ‘ This is Variant type by default

Set objAcct = New CAccount
Call objAcct.OC_Connect ("AppServer://myhost:2054", "guest", "guest", "")

Set ProTT = New CProTempTable

Call objAcct.GetDirectDeposit(ProTT)

‘ Get an array of Field objects
flds = ProTT.Fields
For j = 1 to 3 ‘ For each of 3 columns
    fld(j) = flds.Item(j)
Next j

For i = 1 to 2  ‘ For each of 2 rows
    ProTT.MoveNext()
    For j = 1 to 3 ‘ For each of 3 columns
        DirDeposit(i, j) = fld(j).Value
    Next j
Next i
ProTT.Close() 

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