Progress Quiz 13

Qn 13: What is the difference between “RUN procname.p” and “RUN procname.p PERSISTENT SET handle” statements?
Ans: 1st one is a call to an external procedure and 2nd one makes procname.p as a persistent procedure for the duration of the called procedure.
 

TomBascom

Curmudgeon
The first variation instantiates and runs the procedure. On return the procedure that you ran is destroyed. If you want to make use of its capabilities in the future you will need to instantiate it again from scratch. The new procedure will not retain any local context from any previous incarnations.

The second variation instantiates the procedure and runs it. When it returns the procedure remains in memory and you can access its resources through the handle (or via less direct means such as a default SUPER procedure or PUBLISH and SUBSCRIBE or walking the widget tree...) without needing to re-instantiate it. The persistent procedure can maintain context via local variables and temp tables.
 
At what point the second variation ends the procedure being available in memory?

If this was included in procedure proc1.p for example, when the control returns out of proc1.p, this persistent procedure will no longer be available as the handle was set only as a local variable in proc1.p. Is that right?
 

TomBascom

Curmudgeon
You are not actually required to "set handle". I pretty much never do that. I almost always have my persistent procedures install themselves as session super procedures. I can then run their internal procedures without a handle reference or any UDFs with a simple "in super" forward definition and, voila! They just work :)
 

TomBascom

Curmudgeon
Persistent procedures stay in memory until they are explicitly removed with DELETE PROCEDURE. Or when the session is terminated.
 
Top