Accessing temp-tables & datasets defined and filled in

Posted by atuldalvi123 on 23-Sep-2016 12:04

How to access the temp-tables at client side defined and filled in appserver startup super procedure ?

All Replies

Posted by Peter Judge on 23-Sep-2016 12:17

They will need to be available to the session /AVM used for a request. Then you can return them as if they were any other data.

How to make and keep them available from the startup procedure is a topic for some discussion but probably the simplest least bad way is to add a function into the session startup procedure - call it GetData() -  that returns a HANDLE or TABLE- or DATASET-HANDLE to the data. The session startup proc runs persistently throughout the  life of the agent/session and you can use this to your advantage.

In your appserver request.p ,  get the handle to the startup.p.

define variable hClientPrincipal as handle no-undo.

define variable hStartupProc as handle no-undo.

hStartupProc = session:first-procedure.

do while valid-handle(hStartupProc) and hStartupProc:name ne 'BusinessLogic/Startup.p':

   hStartupProc = hStartupProc:next-sibling.


Do something like the above and make sure you have the name right :D

Now you can call your GetData call

assign hBuffer = dynamic-function('GetData' in hStartupProc))).

When calling the GetData() call make sure to not perform deep copies and cause memory leaks. See the BY-REFERENCE keyword and similar techniques (passing handles etc).

There are other ways that add global state (using shared constructs etc) but whether you choose those approaches depends on your app architecture and your design principles and feelings about global state. Mine is generally that it’s bad and to avoid as far as possible.

Posted by Peter Judge on 23-Sep-2016 12:34

You can certainly use it for the definitions. You cannot for the data.

Posted by atuldalvi123 on 23-Sep-2016 12:38


Posted by atuldalvi123 on 28-Sep-2016 09:44

Thanks Peter. But here I am not using any BY-REFERENCE keyword for the output dataset and still it works for me.

and so I am not sure on whether I am using the correct coding steps or not.

U can have a look on my below code as well -

/******  Super proc - StartSup.p **** Running continuously on appserver  ******/

{dsPars.i}   /* Having dataset and temp table def */



/* logic to fill data set and temp tables  */



/* function to return dataset as a handle */




/********* Caller ******** caller.p *******/

{dsPars.i}  /* Same .i */



logic to use the dataset & temp tables



PROCEDURE getParams:



       hDsPars = DYNAMIC-FUNCTION("getParamts").  /* Call to the appserver super proc function */ 


       DELETE OBJECT hDsPars.



Do I need to delete the output DataSet here aswell or have to use by-reference keyword for the output dataset  ?

This thread is closed