Setting Up Memory Tables

Memory tables are useful when a program needs to create a temporary database table for a fast search, sort, or sequential access, such as with DAL scripts with DALDB. For instance, you create a few database tables from the input extract XML file for easier mapping and searching if those tasks were taking too long.

To tell the system to open a memory table in a DAL script, include the MEM or MEMORY parameter as the database type. This is the second parameter of DBOpen function. Here is an example:

rc=DBOpen("tablel","MEM","d:\deflib\appidx.dfd","READ & WRITE"); 

Keep in mind that since the tables are in memory, they go away once the program terminates and the data is lost. DFD files are required to use memory tables since those tables are not self-describing.

When you use a memory table with either a DAL script that did not specify the MEM parameter or with some other kind of table, include one of these INI options to tell the system the table will be using memory:

< DBTable:XXX >
  DBHandler = MEM 

or

< DBTable:XXX > 
  DBHandler = MEMORY

To keep the table in memory after the DBClose call, include this INI option:

< DBTable:XXX >
  Persistent = Yes

Keep in mind, in this case table memory is released only when the program terminates. Use carefully to make sure you do not run out of memory.