Try OpenEdge Now
skip to main content
Guide for New Developers
An overview of ABL : Accessing Data : Temporary Tables (TEMP-TABLES)
 

Temporary Tables (TEMP-TABLES)

An important ABL construct is the temporary table (temp-table). A temp-table gives you nearly all the features of a database table, and you can use a temp-table in your procedures almost anywhere you could reference a database table. However, temp-tables are not persistent. They are not stored anywhere permanently. They are also private to your own OpenEdge session, the data you define in them cannot be seen by any other users.
You can define sets of data using temp-tables that do not correspond to tables and fields stored in your application database, which gives you great flexibility in how you use them. You can also use a temp-table to pass a whole set of data from one procedure to another, or even from one OpenEdge session to another. Together, queries and temp-tables provide much of the basis for how data is passed from one application module to another. They are essential to creating distributed applications, with data and business logic on a server machine and many independent client sessions running the user interface of the application.
Temporary tables are database tables that OpenEdge stores in a temporary database. Unlike regular database tables, which are permanent and which multiple users can access simultaneously, temporary tables last only for the duration of the procedure that defines them (or for the duration of the OpenEdge session, if you make them GLOBAL), and allow only one user at a time to access them. Finally, temporary tables are private, visible only to the user (process) that creates them. In short, if you want to sort, search, and process data for a duration not longer than the OpenEdge session, use temporary tables.
OpenEdge stores temporary tables and temporary files in the same directory—by default, your current working directory. You can change this directory by using the Temporary Directory (–T) startup parameter. Temporary tables require less memory than large work tables.
Note: You cannot access temporary tables using SQL statements.
You define a temporary table by using the DEFINE TEMP–TABLE statement. For example, the following statement defines temporary table Temp–Cust that inherits the field definitions of table Customer, which must belong to a database that is connected.
DEFINE TEMP-TABLE Temp-Cust LIKE Customer.