Kbase P87109: How to retrieve Temp-table data from Appserver using Delphi ?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  16/10/2008 |
|
Status: Unverified
GOAL:
How to retrieve Temp-table data from Appserver using Delphi ?
GOAL:
How to output data from Openclient to a Delphi application ?
FACT(s) (Environment):
Progress 9.x
OpenEdge 10.x
FIX:
1 - Create a 4GL program (getdata.p) which is going to populate the temp-table and send it back to the Open client as an output parameter. The program can be saved in the working directory:
DEFINE temp-table tcust
FIELD tcustnum AS INTEGER
FIELD tname AS CHARACTER FORMAT "X(20)".
DEFINE OUTPUT PARAMETER TABLE FOR tcust.
FOR EACH customer NO-LOCK:
CREATE tcust.
ASSIGN tcustnum = customer.custnum
tname = customer.NAME.
END.
2 - Connect to the sports database and compile getdata.p program.
3 - Run proxygen and create an activex proxy named test.dll containing the procedure above.
4 - Register the generated DLL runnning: regsvr32 test.dll.
5 - Start your Name Server NS1 and AppServer asbroker1 connecting to a sports database using default values for the port numbers ( 5162 for the NS1).
6 - Copy the program below to your notepad and save it as testprg.pas:
unit testprg;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComObj;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
AppServer : Variant;
TempTable : Variant;
count1 : integer;
Data : Variant;
Data2 : Variant;
begin
// Connect to the AppServer
AppServer := CreateOleObject('test');
AppServer.OC_Connect('AppServer://localhost:5162/asbroker1', '', '', '');
edit1.Text := 'Connected';
TempTable := CreateOleObject('Progress.TempTable.2');
// Run procedure GetData on the appserver
AppServer.GetData(TempTable);
for Count1 := 1 to 10 do
begin
TempTable.MoveNext;
Data := TempTable.Fields.Item[1].value[0];
Data2 := TempTable.Fields.Item[2].value[0];
Edit1.Text := Data;
Edit2.Text := Data2;
MessageDlg('Ok for next customer!!', mtInformation,
[mbOk], 0);
end;
TempTable.Close;
AppServer.OC_Release;
end;
end.
7 - Open your Delphi and run program above, you will see 2 Edit boxes being populated with custnum and customer name for the first 10 customers.