Kbase P87301: A WRITE trigger appears to always use the name of the buffer defined in the calling procedure?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  07/07/2004 |
|
Status: Unverified
SYMPTOM(s):
A WRITE trigger appears to always use the name of the buffer defined in the calling procedure?
/* CallingProcedure.p */
DEFINE VARIABLE rwRecord AS ROWID NO-UNDO.
DEFINE BUFFER Alpha FOR Customer.
FIND FIRST Alpha NO-LOCK.
ASSIGN
rwRecord = ROWID (Alpha).
RUN CalledProcedure.p(rwRecord).
/* CalledProcedure.p */
DEFINE INPUT PARAMETER rwRecord AS ROWID.
DEFINE BUFFER Beta FOR Customer.
FIND FIRST Beta WHERE ROWID(Beta) = rwRecord EXCLUSIVE-LOCK NO-ERROR.
ASSIGN
NAME = "some new value".
/* WRITE trigger */
TRIGGER PROCEDURE FOR Write OF Customer
NEW BUFFER Customer-new
OLD BUFFER Customer-old.
MESSAGE BUFFER Customer-new:NAME
VIEW-AS ALERT-BOX.
CAUSE:
The code given above behave as expected because a free reference to a buffer causes Progress to raise the scope of that buffer to a higher block. In CallingProcedure.p, the reference to the buffer Alpha is a free reference, hence its scope is the whole procedure and that is why its name is messaged when the WRITE trigger fires.
FIX:
The progress Programming manual states: "If you have a free reference to a
buffer, Progress tries first to scope that buffer to the nearest enclosing block
with record scoping properties. However, other references to the same buffer
outside that block cause Progress to raise the scope to a higher block. "
If we strong scope the reference to the buffer Alpha in CallingProcedure.p, then the WRITE trigger would message the name of the buffer Beta of CalledProcedure.p:
DEFINE VARIABLE rwRecord AS ROWID NO-UNDO.
DEFINE BUFFER Alpha FOR Customer.
DO FOR Alpha:
FIND FIRST Alpha NO-LOCK.
ASSIGN
rwRecord = ROWID (Alpha).
END.
RUN CalledProcedure.p(rwRecord).