Try OpenEdge Now
skip to main content
ABL Essentials
Defining and Using Temp-tables : Using a temp-table as a parameter : Temp-table parameter syntax
 

Temp-table parameter syntax

The syntax you use to pass a temp-table as a parameter is special in order to identify the temp-table to ABL. In the calling routine, you define the parameter in the RUN statement with this syntax:

Syntax

[ INPUT | INPUT-OUTPUT | OUTPUT ] TABLE temp-table-name [ APPEND ]
  [ BY-REFERENCE ][ BIND ]
If you are passing a temp-table as a parameter to another routine, you must add the TABLE keyword before the temp-table name. As with other parameter types, the default direction of the parameter is INPUT.
An INPUT parameter moves data from the calling routine to the called routine at the time of the RUN statement. An OUTPUT parameter moves data from the called routine to the calling routine when the called routine terminates and returns to its caller. An INPUT-OUTPUT parameter moves data from the calling routine to the called routine at the time of the RUN, and then back to the calling routine when the called routine ends.
If you use the APPEND option for an OUPUT or INPUT-OUTPUT temp-table, then the records passed back from the called routine are appended to the end of the data already in the temp-table in the calling routine. Otherwise, the new data replaces whatever the contents of the temp-table were at the time of the call.
If you use the BY-REFERENCE option, the calling routine and the called routine access the same temp-table instance. That is, both routines access the calling routine's instance and ignore the called routine's instance.
If you use the BIND option, a temp-table defined as reference-only in one routine binds to a temp-table instance defined and instantiated in another local routine.
In the called routine, you must define temp-table parameters in this way for an INPUT or INPUT-OUTPUT table:

Syntax

DEFINE [ INPUT | INPUT-OUTPUT] PARAMETER TABLE FOR
  temp-table-name
[ APPEND ][ BIND ].
Once again, INPUT is the default. If you use the APPEND option for an INPUT or INPUT-OUTPUT temp-table parameter to a called routine, then the records passed in from the calling routine are appended to the end of the data already in the local temp-table. Otherwise, the new data replaces whatever the contents of the temp-table were at the time of the call.
For an OUTPUT temp-table parameter returned from a called routine, use this syntax:

Syntax

DEFINE OUTPUT PARAMETER TABLE FOR temp-table-name [ BIND ].
You must define the temp-table in both routines. The temp-table definitions must match with respect to the number of fields and the data type of each field (including the array extent if any). The field data types make up what is called the signature of the table.
Other attributes of the tables can be different. The field names do not have to match. The two tables do not need to have matching indexes, because the AVM dynamically builds the appropriate indexes for the table when it is instantiated either as an INPUT parameter in the called routine or as an OUTPUT parameter in the calling routine. Other details, such as field labels and formats, also do not have to match.
You can pass a temp-table parameter by value, by reference, or by binding. The next sections describe how to decide which option to use based on how you want to pass the temp-table data. Some of this material includes references to running internal procedures in persistent procedure handles. Internal procedures were explained in RunningABL Procedures.