Try OpenEdge Now
skip to main content
ProDataSets
ProDataSet Parameters : Passing a ProDataSet with BY-REFERENCE or BIND : Passing a ProDataSet parameter by reference : Specifying BY-VALUE in the called procedure
 
Specifying BY-VALUE in the called procedure
The parameter list shared by the calling procedure and the called procedure represents a contract between the two procedures that defines how they exchange data. As the cases we explored above illustrate, passing a ProDataSet BY-REFERENCE is a valuable optimization but one with side effects that change the nature of the contract between caller and callee. In some cases, the called procedure might want to force a ProDataSet parameter to be passed by value, regardless of any optimization used by the caller, to enforce the contract of its parameter list, and to avoid some of the side effects that can occur. For example, the called procedure might have some reason why it has to reference the ProDataSet handle in its main block and have that handle retain its validity inside internal procedures. Or, it might need to insist that an INPUT parameter should not result in the caller being able to see changes made to the ProDataSet in the called procedure. In any such case, the called procedure can include the BY-VALUE keyword in its parameter definition to force the ProDataSet to be passed by value, regardless of the caller.
This is the syntax for the DEFINE PARAMETER DATASET statement using BY-VALUE:

Syntax

DEFINE [ INPUT | OUTPUT | INPUT-OUTPUT ] PARAMETER
  DATASET FOR dataset-name BY-VALUE.

Or

DEFINE [INPUT | OUTPUT | INPUT-OUTPUT] PARAMETER
  DATASET-HANDLE dataset-handle BY-VALUE.