By default, when you terminate a called Maintain procedure, Maintain clears its data from memory to save space. You can optimize your application's performance by specifying, each time you terminate a called procedure, how you want Maintain to handle the data of the procedure. You have two options, based on how often you call a given procedure over the course of an application.
If you call the procedure frequently, use the KEEP option to make the procedure run faster by retaining its data between calls.
This option provides data continuity. The data carries over from the end of one invocation to the beginning of the next. The next time you call the procedure, its variables and data source position pointers start out with the same values that they held when the procedure was last terminated. You can use these values or reinitialize them using the DECLARE (or COMPUTE) and REPOSITION commands.
Variables passed by the parent procedure are not affected by data continuity, since the child procedure receives them directly from the parent procedure at the beginning of each call.
KEEP affects transaction integrity in the following way. The KEEP option does not issue an implied COMMIT command at the end of a child procedure. When a child procedure with an open logical transaction returns to its parent procedure and specifies KEEP, the transaction continues into the parent.
If you rarely call the procedure, use the RESET option to reduce memory consumption by freeing the data at the end of each call.
This option does not provide data continuity. All of the variables and data source position pointers of the procedure are automatically initialized at the beginning of each procedure.
RESET affects transaction integrity in the following way. The RESET option issues an implied COMMIT command at the end of a child procedure. When a child procedure with an open logical transaction returns to its parent procedure using RESET, the transaction is closed at the end of the child procedure.
For more information about transactions spanning procedures, see Ensuring Transaction Integrity.
You can specify how a procedure will handle its data in memory by terminating it with the GOTO END command qualified with the appropriate memory-management phrase. The syntax is
GOTO END [KEEP|RESET];
Terminates the procedure, but keeps its data, the values of its variables and data source position pointers in memory. It remains in memory through the next invocation, or (if it is not called again) until the application terminates. The procedure does not issue an implied COMMIT command to close an open logical transaction.
Terminates the procedure, clears its data from memory, and issues an implied COMMIT command to close an open logical transaction. RESET is the default value.
You can use both options in the same procedure. For example, when you are ready to end a child procedure, you can evaluate what logic the procedure has to perform when it is next called and then branch accordingly either to keep data in memory, saving time and providing data continuity, or else to clear data from memory to conserve space.
Note: If you call a procedure with the DROP option, WebFOCUS Maintain will clear the data from the called procedure from memory, no matter what option you choose in the called procedure.