A quicker way of deleting In-Memory table?

Tags: #<Tag:0x00007f2253c95b18> #<Tag:0x00007f2253c95a50>

I have a standard in-memory table (defined in DCT) and a standard ABC Browse box on it.

When I load a window I load data manually to it and it works. But I need to load different data depending on settings from the same window - so I need to re-load my table. and so I need to empty/delete the table somehow quickly.

the standard loop takes awhile

clear(pre:record)
set(table)
    LOOP        
        NEXT(table)
        IF ERRORCODE() THEN BREAK.
        DELETE(table)        
    .   

so is there any way to delete all records (empty) in-Memory table that is currently used in BrwoseBox??

Close the table, then CREATE(Table) ?

1 Like

I would think that Empty(table) would work if Create does.

2 Likes

I always just looped backwards through the file. That way you don’t have to worry about having exclusive access, and it’s pretty dang fast anyway. But if this is something you do a lot, maybe it’s worth the effort to get exclusive access (closing the file in every thread first).

1 Like

I think this code was from Arnor (for ABC):

 EmptyIMDDtable       PROCEDURE  (FileManager pFM)        
  CODE
        Loop pFM.GetOpened() TIMES
            pFM.close()
        end ! loop
        remove(pFM.File)
        create(pFM.File)
        return
1 Like

I would like to know if EMPTY was tested and worked?

The Docs have an example that show the file Must Be OPEN(,18) as 18=12h= DenyAll + ReadWrite so exclusive. This is the same for disk TPS. Elsewhere it mentions Open Mode is used to “enforce access between threads”. So you probably must Close and Open.

Docs say EMPTY is supported:

image

1 Like

Carl,
Have tried EMPTY even with close and open, and open with 12h - it (empty) returns always 63 error

Your table must be opened in exclusive mode. You can do in Individual Files Overrides.

I never could get it to empty unless I closed the window, so in the end we constructed a ram drive and ran tps files on the ram drive instead.

List of RAM drive software - Wikipedia

fwiw.

63 = Exclusive Required. It must not have closed, you could check Status(File)

Do you just need the file on 1 thread?

Then you could set templates to always Open(,12h) exclusive so EMPTY would work. You specify /THREADEDCONTENT i.e. DRIVER('Memory', '/THREADEDCONTENT’) and each thread gets its own instance.

I would still leave your existing Loop ; Next ; Delete code after EMPTY() in case the Open changed.

1 Like