Consultor Eletrônico



Kbase P112397: When does Progress create dynamic TEMP-TABLEs automatically?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   16/10/2008
Status: Verified

GOAL:

When does Progress create dynamic TEMP-TABLEs automatically?

GOAL:

At which times are TEMP-TABLEs created implicitly?

GOAL:

Does using TABLE-HANDLE parameters cause new TEMP-TABLE objects to be created?

GOAL:

How to handle TEMP-TABLE objects created by using TABLE-HANDLE parameters

FACT(s) (Environment):

All Supported Operating Systems
Progress 9.x
OpenEdge 10.x

FIX:

There are some occasions in which the Progress 4GL creates dynamic TEMP-TABLEs automatically, that is, without resorting to an explicit CREATE TEMP-TABLE statement. Be aware that, even if created implicitly by Progress, these dynamic TEMP-TABLEs are *not* deleted automatically by Progress; they must be deleted explicitly by the 4GL program via a DELETE OBJECT statement instead, otherwise problems can occur such as memory leaks, abnormal growth of a client?s DBI file, or error 40 ("SYSTEM ERROR: Attempt to define too many indexes.").

This is the list of known conditions:

a) When running a procedure with an INPUT-OUTPUT or OUTPUT TABLE-HANDLE parameter, the called procedure has a static TABLE parameter and the handle variable used to catch the result does not point to a valid existing TEMP-TABLE, as in the following exemplified code:

DEFINE VARIABLE hTable AS HANDLE NO-UNDO.

RUN myProcedure (OUTPUT TABLE-HANDLE hTable).

PROCEDURE myProcedure :
DEFINE OUTPUT PARAMETER TABLE FOR tt.
...
END.

In this case, Progress implicitly creates a dynamic TEMP-TABLE with a schema identical to TEMP-TABLE tt and assigns its handle to variable hTable. This TEMP-TABLE must be deleted explicitly when it?s no longer needed:

RUN myProcedure (OUTPUT TABLE-HANDLE hTable).
...
Use hTable
...
DELETE OBJECT hTable.

Executing a RUN with INPUT or INPUT-OUTPUT TABLE-HANDLE does not exhibit this behavior, because hTable must point to a pre-existing TEMP-TABLE and Progress will use that TEMP-TABLE instead of creating an implicit dynamic one.
Similarly, if the receiving variable points to an existing valid TEMP-TABLE that TEMP-TABLE will be used to catch the returned data.

b) Whenever the called procedure has a dynamic INPUT or INPUT-OUTPUT TABLE-HANDLE parameter, as in the following exemplified code:

RUN myProcedure (INPUT TABLE tt).

PROCEDURE myProcedure :
DEFINE INPUT PARAMETER TABLE-HANDLE phTable.
...
END.

Progress implicitly creates a dynamic TEMP-TABLE with a schema identical to the TEMP-TABLE passed to the procedure, but does not delete it at the end of the procedure; the dynamic TEMP-TABLE must be deleted explicitly instead as in the following:

PROCEDURE myProcedure :
DEFINE INPUT PARAMETER TABLE-HANDLE phTable.
...
DELETE OBJECT phTable.
END.

Note that if an OUTPUT TABLE-HANDLE parameter is used, it will remain uninitialized until it is used to explicitly create a new dynamic TEMP-TABLE or until it is assigned the value of the handle for an existing TEMP-TABLE.

Be aware that under all circumstances, the DELETE OBJECT statement is not executed immediately when executed on a dynamic TABLE-HANDLE parameter. The delete is actually delayed until after the TEMP-TABLE has been copied back to the caller.


If the procedure contains multiple RETURN statements, ensure that each point where the procedure RETURNs has the appropriate DELETE OBJECT statement(s). For example:

PROCEDURE myProcedure :
DEFINE INPUT PARAMETER TABLE-HANDLE phTable.
...
IF <some condition> THEN DO:
DELETE OBJECT phTable.
RETURN.
.END.
...
DELETE OBJECT phTable.
END.

c) When passing DATASETs across procedures, dynamic TEMP-TABLEs are implicitly created in exactly the same cases as when passing TEMP-TABLES (points a and b above), that is:
1) When running a procedure with an INPUT-OUTPUT or OUTPUT DATASET-HANDLE parameter, the called procedure has a static DATASET parameter and the handle variable used is invalid,
2) Whenever the called procedure has a dynamic INPUT or INPUT-OUTPUT DATASET-HANDLE parameter.

These need to be addressed by deleting the dynamic DATASET implicitly created, by means of a DELETE OBJECT statement in the appropriate place. Deleting the dynamic DATASET will delete the dynamic TEMP-TABLEs created with it as well.

In order to check whether there are dynamic TEMP-TABLEs in the clients memory which have not been properly deleted, refer to Solution P113170..