Kbase P130313: 4GL/ABL: How are the BIND and the REFERENCE-ONLY options used when passing a TEMP-TABLE parameters?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  9/17/2009 |
|
Status: Verified
GOAL:
4GL/ABL: How are the BIND and the REFERENCE-ONLY options used when passing a TEMP-TABLE parameters?
GOAL:
When were the BIND and the REFERENCE-ONLY options introduced for passing a TEMP-TABLE parameter?
GOAL:
What is the benefit of passing a TEMP-TABLE parameter with the BIND and the REFERENCE-ONLY options?
GOAL:
What is scope of the passed TEMP-TABLE when the BIND and the REFERENCE-ONLY options for passing a TEMP-TABLE parameter was introduced?
GOAL:
How to bind a called procedure TEMP-TABLE to the calling procedure?
GOAL:
How to bind a calling procedure TEMP-TABLE to the called procedure?
FACT(s) (Environment):
All Supported Operating Systems
OpenEdge 10.1x
FIX:
Starting with OpenEdge Release 10.1A, the BIND and the REFERENCE-ONLY options were introduced to save the overhead of copying the TEMP-TABLE definition and data when passed as a parameter on local calls.
The scope the TEMP-TABLE of the calling procedure that is passed with the BIND and the REFERENCE-ONLY options is the same as that of the calling procedure itself. The scope of the TEMP-TABLE of the called procedure that is passed with the BIND and the REFERENCE-ONLY options is the same as that of the called procedure itself. In other words, the scope of the TEMP-TABLE is the same as that of its owner where it is defined without the REFERENCE-ONLY option.
Although the calling procedures in the following examples RUN the called procedures PERSISTENT, persistency is NOT a prerequisite for the use of BIND and the REFERENCE-ONLY options when passing temp tables.
1. In the following example, the called procedure TEMP-TABLE is bound to the calling procedure. Hence, its scope is that of the called procedure:
/* Procedure: Calling1.p */
/* How to bind a called procedure TEMP-TABLE to the calling procedure*/
DEFINE VARIABLE hProc AS HANDLE NO-UNDO.
DEFINE TEMP-TABLE ttCallingTable REFERENCE-ONLY
FIELD iField AS INTEGER
FIELD cField AS CHARACTER.
RUN Called1.p PERSISTENT SET hProc.
RUN PopulateCalledRoutineTempTable IN hProc.
RUN BindCalledTempTableToCaller IN hProc (OUTPUT TABLE ttCallingTable BIND).
FIND FIRST ttCallingTable.
MESSAGE iField cField
VIEW-AS ALERT-BOX INFO BUTTONS OK.
/**************************************************************/
/* Procedure: Called1.p */
DEFINE TEMP-TABLE ttCalledTable
FIELD iField AS INTEGER
FIELD cField AS CHARACTER.
PROCEDURE PopulateCalledRoutineTempTable:
CREATE ttCalledTable.
ASSIGN
iField = 1
cField = "I am the called procedure TEMP-TABLE. Hence, my scope is the same as that of called procedure, Called1.p ".
END PROCEDURE.
PROCEDURE BindCalledTempTableToCaller:
DEFINE OUTPUT PARAMETER TABLE FOR ttCalledTable BIND.
END PROCEDURE.
2. In the following example, the calling procedure TEMP-TABLE is bound to the called procedure. Hence, its scope is that of the calling procedure:
/* Procedure: Calling2.p */
/* How to bind a calling procedure TEMP-TABLE to the called procedure*/
DEFINE VARIABLE hProc AS HANDLE NO-UNDO.
DEFINE TEMP-TABLE ttCallingTable
FIELD iField AS INTEGER
FIELD cField AS CHARACTER.
RUN PopulateCallingRoutineTempTable IN THIS-PROCEDURE.
RUN Called2.p PERSISTENT SET hProc.
RUN BindCallingTempTableToCalled IN hProc (INPUT TABLE ttCallingTable BIND).
RUN DisplayttCallingRoutineTable IN hProc.
PROCEDURE PopulateCallingRoutineTempTable:
CREATE ttCallingTable.
ASSIGN
iField = 1
cField = "I am the calling procedure TEMP-TABLE. Hence, my scope is the same as tha.t of calling procedure, Calling2.p ".
END PROCEDURE.
/**************************************************************/
DEFINE TEMP-TABLE ttCalledTable REFERENCE-ONLY
FIELD iField AS INTEGER
FIELD cField AS CHARACTER.
PROCEDURE BindCallingTempTableToCalled:
DEFINE INPUT PARAMETER TABLE FOR ttCalledTable BIND.
END PROCEDURE.
PROCEDURE DisplayttCallingRoutineTable:
FIND FIRST ttCalledTable.
MESSAGE iField cField
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END PROCEDURE..