Pass a temp-table by reference
- Last Updated: December 14, 2023
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
When you pass a temp-table and the routine call is local, you can tell the AVM
to optimize the call by having the called routine refer to the instance of the temp-table
already in the calling routine. You tell the AVM to share a single instance of the temp-table
by including the BY-REFERENCE keyword on the caller's RUN statement:
Syntax
|
Passing the caller's temp-table BY-REFERENCE saves all
the overhead of copying the temp-table definition and data. If the
call is remote, then the AVM ignores the BY-REFERENCE keyword
and passes the temp-table by value, as it must in that case.
When you pass a temp-table parameter by reference, the called routine's temp-table definition is bound to the calling routine's temp-table only for the duration of the call.
To pass a temp-table by reference, in the calling routine, use
the BY-REFERENCE keyword in the RUN statement
that defines the temp-table parameter. There is no special syntax required
in the called routine. However, since the calling routine's temp-table instance
is substituted for the called routine's temp-table, only the definition
of the temp-table is required by the called routine. In other words,
the same temp-table is defined in both routines but only one is
actually used. If the called routine's temp-table is not directly
used to hold its own data anywhere within the routine, you can save
the overhead of allocating it by including the REFERENCE-ONLY keyword
on its definition:
|
This keyword tells ABL to use the definition for compiler references
to the table and its fields but not to instantiate it at run time.
Any reference to the temp-table, except where it is passed in from
another routine BY-REFERENCE, results in a runtime error.