Kbase P102705: How to call external procedure from schema trigger ?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  31/03/2005 |
|
Status: Unverified
GOAL:
How to call external procedure from schema trigger ?
GOAL:
Why can't an external procedure called from a schema trigger access the record that caused the trigger to fire ?
FIX:
The thing to keep in mind when calling an external procedure from a schema trigger (defined in either the session or the database), it will run in it's own context.
Because of this it will not be aware of the record that caused the trigger to fire unless it is explicitly made aware. To do so, use BUFFER parameters to pass the buffers used in the trigger.
Using a WRITE trigger for example, it will look like:
ON WRITE OF MyTable OLD BUFFER oldMyTable
DO:
RUN myProcedure.p (BUFFER MyTable, BUFFER oldMyTable).
END.
myProcedure.p will look like:
/* myProcedure.p */
DEFINE PARAMETER BUFFER MyTable FOR MyTable.
DEFINE PARAMETER BUFFER oldMyTable FOR MyTable.
/* insert logic here */