Progress
Programming
Handbook
Dynamic Temp–tables as Local and Remote Parameters
Using a temp–table as a parameter requires the ability to send the template of the temp–table, its index–information, and its field information locally to a local procedure or remotely to an AppServer.
The DEFINE PARAMETER and RUN statements support sending the table–handle as a parameter as shown below:
For more information on parameter syntax, see the DEFINE PARAMETER statement and the RUN statement in the Progress Language Reference manual.
INPUT
If the parameter is INPUT TABLE–HANDLE, the definition behind the handle plus the contents of the temp–table are sent from the caller to the called routine. The called routine can have either a dynamic INPUT TABLE–HANDLE or a static INPUT TABLE as a matching parameter.
In the called routine, a new instance of the temp–table is created along with its handle, completely separate from the caller’s table and populated with the contents from the caller’s table. This instance is used during the called routine. If the called routine has a static table as the matching parameter, the caller temp–table data will be loaded into this table. In no case is the caller’s table affected by the called procedure.
OUTPUT
If the parameter is OUTPUT TABLE–HANDLE, the handle plus the definition behind the handle are sent from the caller to the called routine. If the handle is NULL, then no definition is sent. The called routine can have either a table handle for a static OUTPUT parameter or a dynamic OUTPUT TABLE–HANDLE as a matching parameter. The called routine returns the definition behind the handle along with the contents of the output temp–table. In the caller, a new instance of the table is created if the original handle was NULL and populated with the returned temp–table contents. This new table replaces any pre-existing table in the caller, either static or dynamic. If the APPEND keyword was used, the returned contents are appended to the pre-existing table, rather than replacing it.
NOTE: For local cases, there is usually no need to use anything more than a simple HANDLE type parameter to allow routines to share a temp–table. The TABLE–HANDLE parameter is only for cases where either one or both sides of a remote communication lack a static definition of the temp–table.INPUT–OUTPUT
If the parameter is INPUT–OUTPUT TABLE–HANDLE, a combination of the above will occur.
The following programs illustrate using a temp–table handle as a parameter. The called program, getdbtable.p, is used to create a temp–table from any database table whose name is passed to it and to pass back the handle to this temp–table. The calling program, passdbname.p, passes the database table name and receives back the temp–table handle which it uses to access the created temp–table.
These programs use dynamic queries which are described in "Using Dynamic Widgets":
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |