Ravi Akkiraju · May 9, 2021

%ClearTable of Ens.Util.LookupTable class is deleting the entire table

As per the documentation, this is supposed to delete the contents of the lookup table, but it is deleting the table as well.

Delete the contents of the lookup table pTable.

Purpose: I need to use a temporary Data lookup table within a DTL for repetition count of a key field. 


Initialize - s tmpTable = ##class(Ens.Util.LookupTable).%New()

Lookup & add new entries


s % = tmpTable.%UpdateValue("myTempTable",sThisPhone,(iCount+1),1)


d tmpTable.%ClearTable("myTempTable")

Either i need a method to create a temp table on the fly so that it can be deleted or just clear the entires. 

really appreciate your help and input in steering me in the right direction.

Thank you,


Product version: IRIS 2019.1
$ZV: IRIS 2019.1
0 109
Discussion (1)1
Log in or sign up to continue

Looks like ClearTable is not the correct method. As per the code, its doing

ClassMethod %ClearTable(pTable As %String)
Kill ^Ens.LookupTable(pTable)

so..i did this but not too comfortable touching the globals directly. Hoping there is a cleaner way... (the below works)..

Table initialization

s tmpTable = ##class(Ens.Util.LookupTable).%New()
s ^Ens.LookupTable("myNiCTmpTable00992314","DUMMYVAL")=0 //create some randomly named table

<....use this tmp table for lookup and adding new rows.>

delete the tmpTable once done with usage

d tmpTable.%ClearTable("myNiCTmpTable00992314")

Edit: Adding a 2 digit random number at the end of the temp table name to ensure no conflict if multiple threads are running at the same time.