use EMPTY TEMP-TABLE

Project:Prolint Issue Tracker
Component:Rules
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

replace

FOR EACH temptablename :
     DELETE temptablename.
END.

by the EMPTY TEMP-TABLE statement, because it is much faster.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Except, in 9.1D we are

Except, in 9.1D we are repeatedly getting burned emptying a temp-table inside a transaction ... at some times a bad thing (and a progress system error) happens at the client. I was actually thinking of a rule to warn people using empty temp-table command inside a transaction. Outside of a transaction though, this is probably a very good idea.


empty-temp-table.i

Here's an include file we use that takes care of several possibilities for emptying temp-tables:

/* 1/30/2004 KGER:
Based on information in Dan Foreman's Performance Tuning Guide (p. 143),
this code has been revised to take advantage of the rules that differ
between versions 9.0 and 9.1. */

DO:
&IF INT(ENTRY(1,PROVERSION,".")) < 9 &THEN
/* In versions prior to v9.0A, a "FOR EACH...DELETE" was the only way to empty a temp-table. */
FOR EACH {1}:
DELETE {1}.
END.
&ELSEIF DEC(SUBSTR(PROVERSION,1,3)) EQ 9.0 &THEN
/* In v9.0, the EMPTY operation would only work outside an active transaction. */
IF TRANSACTION THEN DO:
FOR EACH {1}:
DELETE {1}.
END.
END.
ELSE DO:
EMPTY TEMP-TABLE {1}.
END.
&ELSEIF DEC(SUBSTR(PROVERSION,1,3)) GE 9.1 &THEN
/* Starting with v9.1A, a NO-UNDO temp-table can be emptied at any time.
Otherwise, the same rules apply as with v9.0 above. */
IF TEMP-TABLE {1}:UNDO AND TRANSACTION THEN
FOR EACH {1}:
DELETE {1}.
END.
ELSE
EMPTY TEMP-TABLE {1}.
&ENDIF
END.