Progress
Open Client
Developer’s Guide


Passing a TEMP-TABLE OR TABLE-HANDLE As an Input Parameter

To pass an input parameter, you must create an object whose methods the proxy can call to obtain the data. In a Visual Basic program, you can provide one of three types of objects:

Whatever mechanism you use, the proxy determines what kind of object you are passing and calls the appropriate methods to access it.

NOTE: This section also applies to the input side of input/output TEMP-TABLE parameters.

The following sections provide information about:

Choosing an Object Type to Pass

If you have access to ADO technology, this is the most flexible mechanism, because you can obtain an ADO Recordset in two ways:

If you do not have access to ADO technology, and the input data resides in a local database, using a DAO Recordset is your best alternative. Otherwise, you must use the IClientTempTable interface.

The source object (the DAO, ADO, or IClientTempTable object) is not passed directly as a parameter. Instead, the client application creates a ProTempTable object and sets its DataSource property to one of these source objects.

The implementation of an Automation object that supports the IClientTempTable interface can obtain the data in whatever way is necessary. For example, it might read the data from an ActiveX Grid control, obtain it from an array variable or load it from of a file. You can find an example of how to implement this interface installed with the Open Client Runtime and located in the directory: Progress-Install-Directory\src\samples\open4gl\IClientTempTable.

The IClientTempTable interface has the following methods:

SYNTAX
MoveNext (Boolean moreRecs) 

Changes the current record to the next row of the Recordset. The current record is initialized to the record before the first record of the set. Therefore, the first time MoveNext() is called it moves to the first record. moreRecs is an output parameter that is set to FALSE when the end of the Recordset is reached.

NOTE: Make sure the result set cursor is positioned before the first row if you plan to pass the InputResultSet as an input parameter, and you want the receiving context to have access to all rows from the beginning of the TEMP-TABLE. Only rows after the current cursor position are passed to the AppServer.

SYNTAX
GetValue(short fldIndex, Variant value) 

Gets the value for the column specified with fldIndex,a 1-based index. This must map to the order in which the fields are defined in the 4GL TEMP-TABLE. For input, a 4GL array field is viewed as a flattened set of columns (see "Programming Concepts"). This is generally convenient in VB because the likely data sources for input Recordsets (such as, grids, arrays, or Access databases) do not themselves support array fields.

Input TEMP-TABLE Parameter Examples For ActiveX

Example 7–1 shows a sample of VB code that takes a TEMP-TABLE input parameter as an ADO Recordset.

Dim objAcct As AccountLib.CAccount
Dim ProTT As ProTempTableLib.CProTempTable
Dim rs As ADOR.Recordset

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

’ Create an ADO Recordset with three column and two rows
Set rs = CreateObject("ADOR.Recordset")
Call rs.fields.Append("AcctNum", adInteger)
Call rs.fields.Append("Amount", adDouble)
Call rs.fields.Append("StartDate", adDate)

Call rs.Open(, , adOpenDynamic)

Call rs.AddNew("AcctNum", 1)
Call rs.Update("Amount", 1000.11)
Call rs.Update("StartDate", 10 / 26 / 53)

Call rs.AddNew("AcctNum", 2)
Call rs.Update("Amount", 2000.22)
Call rs.Update("StartDate", 1 / 1 / 2000)

SetProt = new CProtempTable
ProTT.DataSource = rs
‘ The proxy calls back through the ADO to get the input data
Call objAcct.SetDirectDeposit (ProTT) 

Example 7–1: ActiveX TEMP-TABLE Input Parameter Using ADO

Example 7–2 shows a sample of VB code that takes a TEMP-TABLE input parameter as a DAO Recordset.

Dim objAcct As AccountLib.CAccount
Dim ProTT As ProTempTableLib.CProTempTable
Dim MyDb As Database
Dim RecSet As Recordset 

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

Set MyDb = OpenDatabase("temp.mdb")
Set RecSet = MyDb.OpenRecordset("DirectDeposit")
Set VBTT = New VBTempTable

ProTT.DataSource = RecSet
‘ The proxy calls back through the DAO RecSet to get the input data
Call objAcct.SetDirectDeposit (ProTT) 

Example 7–2: ActiveX TEMP-TABLE Input Parameter Using DAO

Example 7–3 shows a sample of VB code that takes a TEMP-TABLE input parameter as an IClientTempTable Automation object. In this example, vbtt.VBTempTable is an object that implements IClientTempTable.

NOTE: You must implement your own IClientTempTable object similar to the example VBTempTable class installed with the Open Client Runtime (see "Choosing an Object Type to Pass" earlier in this section).

Dim objAcct As AccountLib.CAccount
Dim VBTT As vbtt.VBTempTable ’An object that implements IClientTempTable
Dim ProTT As ProTempTableLib.CProTempTable

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

Set ProTT = New CProTempTable

ProTT.DataSource = VBTT
‘ The proxy calls back through VBTT to get the input data
Call objAcct.SetDirectDeposit (ProTT) 

Example 7–3: ActiveX TEMP-TABLE Input Parameter Using IClientTempTable

Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095