Try OpenEdge Now
skip to main content
ABL Essentials
Defining and Using Temp-tables : Using temp-tables in your application : Defining a temp-table : Temp-table scope
 
Temp-table scope
Generally speaking, the scope of a temp-table is the procedure in which it is defined. In fact, you can only define a temp-table at the level of the whole procedure, not within an internal procedure. When the procedure terminates, any temp-tables defined in it are emptied and deleted. Likewise, a temp-table is visible only within the procedure that defines it. If that procedure passes the temp-table by value to another procedure, the other procedure has to have its own definition of the temp-table, and it obtains a copy of the temp-table when it receives it as an INPUT parameter.
Alternately, you can use optional syntax to share a temp-table reference between procedures. This is discussed in Usinga temp-table as a parameter.
There are several other aspects of temp-table scope that are beyond the scope of this book:
*It is possible to send a temp-table to another procedure that has no prior definition of the temp-table, but instead receives the definition along with the temp-table data. This involves the use of dynamic temp-tables.
*There are keywords to define a temp-table to be SHARED between procedures, and also to make the scope and visibility of the temp-table GLOBAL to the entire session. You need to think about the relationship between different procedures in an OpenEdge application to understand properly when you should and should not use shared or global objects such as temp-tables.
*You can pass the handle to a temp-table from one procedure to another within a session, to avoid actually copying the temp-table between procedures. For the purposes of this introduction to temp-tables, think of them as being statically defined and scoped to a single procedure.