Consultor Eletrônico



Kbase 19322: OPEN CLIENT: Sample Delphi Procedure For Output Temp-Table
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/15/2008
Status: Verified

GOAL:

How to retrieve the data from an output temp-table in Delphi 5.

FIX:


procedure TForm1.Button1Click(Sender: TObject);
var
  AppServer   : Variant;
  TempTable   : Variant;
  RecordCount : Integer;
  Count1      : Integer;
  Count2      : Integer;
  Data        : Variant;

begin

  // This code connects to the AppServer, invokes a 4GL program that
  // passes back a temptable with six (6) fields in each record and
  // assigns each data element to the variable called "Data".  This
  // assignment is not of much use but you can use the debugger in
  // Delphi to "watch" this variable and see that the correct data
  // is being returned.  A real application would store this data
  // off somewhere.

  AppServer := CreateOleObject('com.progress.kbase.KBaseObject');

  AppServer.OC_Connect('AppServer://myhost:5162/kbase', '', '', '');

  TempTable := CreateOleObject('Progress.TempTable');

  AppServer.GetData('aaa', 'bbb', RecordCount, TempTable);

  for Count1 := 1 to RecordCount do
      begin
          TempTable.MoveNext;
          for Count2 := 1 to TempTable.Fields.Count do
              Data := TempTable.Fields.Item[Count2].Value[0];
      end;

  TempTable.Close;

  AppServer.OC_Release;
end;