TABLE-HANDLE form with BIND
- Last Updated: May 26, 2026
- 3 minute read
- OpenEdge
- Version 12.8
- Documentation
To pass a TABLE-HANDLE by binding, you must specify the
BIND keyword in both the calling and the called routines to tell
the AVM to use the same temp-table instance for both routines. If the temp-table that
will be used as a pointer is static, use the REFERENCE-ONLY keyword
when you define the temp-table.
|
REFERENCE-ONLY):
|
|
REFERENCE-ONLY if it is static:
|
For example, if you are using the called routine’s temp-table data, you define the
calling routine’s static temp-table as REFERENCE-ONLY. If you are using
the calling routine’s temp-table data, you define the called routine’s static temp-table
as REFERENCE-ONLY.
Alternately, if the unused temp-table is dynamic, you should set the
TABLE-HANDLE parameter to UNKNOWN.
Example
In the following sample code, ProcA.p builds a dynamic
temp-table at run time and runs ProcB.p persistently. It then
calls ProcB's bindTable internal procedure
once, passing the temp-table handle with the BIND keyword. This
binds the temp-table to ProcB.p for the life of the persistent
procedure.
ProcB.p declares a static REFERENCE-ONLY
temp-table whose definition matches the caller's dynamic table. The
REFERENCE-ONLY keyword tells the AVM not to allocate storage
for ProcB.p's definition, because at run time it shares the storage
allocated by ProcA.p. Because ProcB.p uses
a static REFERENCE-ONLY definition, its parameter is declared with
the TABLE FOR ttShared BIND form rather than
TABLE-HANDLE. After the initial bind,
ProcA.p calls ProcB.p's
addRecords internal procedure with no parameters. The binding
established earlier means ProcB.p still operates on
ProcA.p's temp-table instance. ProcA.p
then reads the records back through the same instance.
BY-REFERENCE, the
BIND keyword must appear on both the calling
RUN statement and the corresponding parameter definition in the
called routine. Once the bind is established with a persistent procedure, you do not
need to pass the temp-table again on subsequent calls.| ProcA.p (caller) |
|---|
|
| ProcB.p (callee) |
|---|
|