Try OpenEdge Now
skip to main content
Debugging and Troubleshooting
Troubleshooting Resources : Other Diagnostics Resources : Run-time diagnostics : Progress.Database.TempTableInfo:GetTableStatHistoryHandle()
 
Progress.Database.TempTableInfo:GetTableStatHistoryHandle()
In order to analyze the data of application temp-tables that are deleted during the session, archive the statistical information provided by _TableStat and _IndexStat virtual system tables. If you set the Progress.Database.TempTableInfo: ArchiveTableStatistics to true, the AVM will archive and maintain the information in a temp-table. You cannot delete the temp-table when archiving is enabled.
The temp-table name is in the table archive, and the index name is in the index archive. The procedure used for creating the table is also archived. The application is able to look at the statistics for a particular temp-table on a given procedure for each instantiation of the temp-table individually, or accumulate the values to obtain the overall statistics for a particular temp-table across all instantiations in a session. Thus, _TableStat and _IndexStat provide control over how you want to handle the temp-tables. The ArchiveTableStatistics property and ArchiveIndexStatistics property enables the archiving of statistics for a temp-table and its index. These properties belong to Progress.Database.TempTableinfo
Note: The statistics are maintained only if their IDs are within the range specified by these startup parameters:-ttbasetable, -ttbaseindex, -tttablerangesize, and -ttindexrangesize.
The following example shows how to archive the statistics for temp-tables and indexes.

Archiving temp-tables and indexes

USING Progress.Database.*.
OUTPUT TO Arch.out.
DEFINE VARIABLE hTableArch AS HANDLE NO-UNDO.
DEFINE VARIABLE hbTableArch AS HANDLE NO-UNDO.
DEFINE VARIABLE hIndexArch AS HANDLE NO-UNDO.
DEFINE VARIABLE hbIndexArch AS HANDLE NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO INITIAL 1.
DEFINE VARIABLE n AS INTEGER NO-UNDO INITIAL 1.
DEFINE VARIABLE retOK AS LOGICAL NO-UNDO.
DEFINE VARIABLE tth AS HANDLE NO-UNDO.
CREATE TEMP-TABLE tth.
DEFINE VARIABLE tth2 AS HANDLE NO-UNDO.
CREATE TEMP-TABLE tth2.
DEFINE VARIABLE hq AS HANDLE NO-UNDO.
DEFINE VARIABLE hHdl AS HANDLE NO-UNDO.
tth:CREATE-LIKE(TEMP-TABLE ttDept:HANDLE).
tth:TEMP-TABLE-PREPARE("tth").
tth2:CREATE-LIKE(TEMP-TABLE ttEmp:HANDLE).
tth2:TEMP-TABLE-PREPARE("tth2").
Progress.Database.TempTableInfo:ArchiveTableStatistics = YES.
Progress.Database.TempTableInfo:ArchiveIndexStatistics = YES.
DELETE OBJECT tth.
DELETE OBJECT tth2.
hTableArch = Progress.Database.TempTableInfo:GetTableStatHistoryHandle().
hIndexArch = Progress.Database.TempTableInfo:GetIndexStatHistoryHandle().
IF VALID-HANDLE(hTableArch) THEN
hbTableArch = hTableArch:DEFAULT-BUFFER-HANDLE.
IF VALID-HANDLE(hIndexArch) THEN
hbIndexArch = hIndexArch:DEFAULT-BUFFER-HANDLE.
create query hq.
hHdl = hbTableArch.
run PrintArchRecs.
hHdl = hbIndexArch.
run PrintArchRecs.
DELETE OBJECT hq.

procedure PrintArchRecs:
MESSAGE SKIP hHdl:NAME.
hq:SET-BUFFERS(hHdl).
hq:QUERY-PREPARE("preselect each " + hHdl:NAME ).
hq:QUERY-OPEN().
REPEAT:
hq:GET-NEXT().
MESSAGE " ".
if hq:QUERY-OFF-END then leave.
IF hHdl:NAME = "_TableStatHist" THEN
MESSAGE hHdl::_Table-name hHdl::_Prog-name hHdl::_Delete-Timestamp.
ELSE
MESSAGE hHdl::_Index-name hHdl::_Prog-name hHdl::_Delete-Timestamp.
END. /* repeat */
end PROCEDURE.
The following example displays the output file for archived temp-tables and indexes.

Output file for archived temp-tables and indexes

_TableStatHist
tth Archive.p 08/05/2011 15:30:56.433
tth2 Archive.p 08/05/2011 15:30:56.433
_IndexStatHist
tth.idx1 Archive.p 08/05/2011 15:30:56.433
tth2.idx2 Archive.p 08/05/2011 15:30:56.433