Run a procedure PERSISTENT
- Last Updated: January 16, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
|
The PERSISTENT keyword in the statement tells the AVM to start the
procedure and to leave it in memory, either until you delete it or until your session
ends.
Optionally, you can use the SET phrase to save off the handle of the new
procedure. You have seen handle variables already. Of particular significance is that
persistent procedures have handles the same as other objects do, so that you can access
them after they have been instantiated by a RUN PERSISTENT statement.
In fact, even a procedure that you run without the PERSISTENT option
has a handle, but you would rarely use it. As noted above, the calling procedure can’t
really execute any code until the procedure it runs terminates, and when that happens
the subprocedure’s handle goes away, so the calling procedure would never have a chance
to use it.
In practice, you almost always use the SET
proc-handle option, because the way you make use of a
persistent procedure is to initiate it with a RUN statement and then to
use its handle afterwards to run entry points inside it. The
proc-handle must be a variable or temp-table field with the
HANDLE data type, defined or accessible in the calling procedure.