Asynchronous run of a program and using the temp-table name !!!!!

Prajan

New Member
I have a problem regarding the using of table name in the query.

For eg I have a program client.p where i have a table name. I have to pass this table name to the serverprog.p program which runs asynchronously from the client.p.

DEFINE VARIABLE async-request AS HANDLE.
DEFINE VARIABLE s-hdl AS HANDLE.
DEFINE VARIABLE customer-name as CHARACTER INITIAL "krishna".
DEF VAR table-name AS CHARACTER NO-UNDO INITIAL "try".
DEF VAR ret AS LOGICAL NO-UNDO.
CREATE SERVER s-hdl.
ret = s-hdl:CONNECT("-AppService pfa-app -H 10.0.1.1 -S 5162").
RUN s/serverprog.p ON s-hdl
ASYNCHRONOUS SET async-request EVENT-PROCEDURE "GetCustNum" (INPUT customer-name, INPUT table-name) "try".
WAIT-FOR PROCEDURE-COMPLETE OF async-request.
PROCEDURE GetCustNum:
DELETE OBJECT SELF.
END.
This is a client.p program. Here I have to pass table-name to the serverprog.p program.


DEFINE INPUT PARAMETER customer-name AS CHARACTER.
DEFINE INPUT PARAMETER table-name AS CHARACTER .
MESSAGE "Server prog" table-name.
DEF TEMP-TABLE tt-try LIKE (......).

FIND FIRST try WHERE try.NAME = customer-name.
CREATE tt-try.
ASSIGN tt-try.NAME = try.NAME
tt-try.roll = try.roll
tt-try.addr = try.addr.

Now this is a serverprog.p program.
In table-name i got the table-name from the client program. Now i have to use this table name in
DEF TEMP-TABLE tt-try LIKE (......).
FIND FIRST (......) WHERE (.....).NAME = customer-name.

Hope to hear solutions from all the progress users. Also Happy Vijaya Dashami to all dear friends.
 

Casper

ProgressTalk.com Moderator
Staff member
If you want to pass tablename as a parameter you should use a dynamic temp-table.

Code:
define input parameter Customer-name as character no-undo.
define input parameter Table-name as character no-undo.
 
define variable hTempTable as handle no-undo.
 
create temp-table htempTable.
 
hTempTable:create-like(Table-name).
..... etc.....
 

Prajan

New Member
Hi
Thanks for the reply. I think the thing I was is a bit different than you told.
I need to put the table name inside the query.
DEF TEMP-TABLE tt-try LIKE (......).
FIND FIRST (......) WHERE (.....).NAME = customer-name.
(......) this needs to be filled with the table name coming from client.p
 

RKR

Member
Hi
Thanks for the reply. I think the thing I was is a bit different than you told.
I need to put the table name inside the query.
DEF TEMP-TABLE tt-try LIKE (......).
FIND FIRST (......) WHERE (.....).NAME = customer-name.
(......) this needs to be filled with the table name coming from client.p

Prajan,

There are 2 possible solutions for your problem. The first solution would be the one that Casper wrote. Create a dynamic temp-table and dynamic query's so your sever program can create retrieve the needed information at runtime. If you want to use the static approach using static temp-tables and find or for each statements then you will need to use include files with arguments.

sample
Code:
DEFINE VARIABLE cTable      AS CHARACTER    INITIAL "customer"  NO-UNDO.
CASE cTable:
    WHEN "Customer" THEN DO:
        {SERVER.i &tablename=customer}
    END.
END CASE.
 
/* server.i */
 
FOR EACH {&tablename}:
    DISP {&tablename}.custnum.
END.

Note that server.p cannot be compiled. You will have to put the uncompilled version on the server so Progress will compile it each time it is needed. This also means that if you do not have the correct Progress licences, for instance at a clients site there will not be a full development version, it will not work.
 

Prajan

New Member
Hi
Once again thank you for the wonderful co-operation and suggestions. I dont want to do these stuffs in a static way. I am preferring the dyanmic temp-table. I am now following Casper path.

I have a hTemptable now.

DEFINE VARIABLE hTemptableAS HANDLE.
CREATE TEMP-TABLE hTemptable.
hTemptable:CREATE-LIKE(table-name).

CREATE SERVER s-hdl.
ret = s-hdl:CONNECT("-AppService pfa-app -H 10.0.1.1 -S 5162").
RUN 'x/xmlcreate.p' ON s-hdl ASYNCHRONOUS SET async-request (INPUT TABLE hTemptable).

But now the problem is it doesnt recoginze the '(INPUT TABLE hTemptable)' of the RUN statement.
 

Prajan

New Member
Hi
Thank you very much for the replies. I am able to solve the problem. :). Once again thank you.
 
Top