A TRIGGER_BEFORE_UPDATE program is a program that you create and that Oracle OLAP checks for by name when an UPDATE statement executes. When the program exists in the same analytic workspace that you are updating, Oracle OLAP executes the program and then, depending on the value returned by the program (if any), either does nor does not update the workspace.
Note:The USETRIGGERS option must be set to its default value of
TRUEfor a TRIGGER_BEFORE_UPDATE program to execute
See also:"Trigger Programs".
You can write the program as a function that returns a
BOOLEAN value. In this case, when the program returns FALSE, Oracle OLAP does not execute the UPDATE statement that triggered the execution of the TRIGGER_BEFORE_UPDATE program; when the program returns
NA, the UPDATE statement executes.
To create a program with the name
TRIGGER_UPDATE, follow the guidelines presented in"Trigger Programs".
Assume that an analytic workspace named
myaw has an TRIGGER_BEFORE_UPDATE program with the following definition.
DEFINE TRIGGER_BEFORE_UPDATE PROGRAM BOOLEAN PROGRAM SHOW JOINCHARS ('calltype = ' CALLTYPE) SHOW JOINCHARS ('triggering event = ' TRIGGER(EVENT)) SHOW JOINCHARS ('triggering subevent = ' TRIGGER(SUBEVENT)) RETURN TRUE END
Assume that you define a
TEXT variable named
myvar and, then, issue an UPDATE statement. The TRIGGER_BEFORE_UPDSATE program executes.
calltype = TRIGGER triggering event = BEFORE_UPDATE triggering subevent = AW
Because the program returned TRUE, the definition for
myvar exists after you detach and reattach the workspace.
AW DETACH myaw AW ATTACH myaw DESCRIBE DEFINE TRIGGER_BEFORE_UPDATE PROGRAM BOOLEAN PROGRAM SHOW JOINCHARS ('calltype = ' CALLTYPE) SHOW JOINCHARS ('triggering event = ' TRIGGER(EVENT)) SHOW JOINCHARS ('triggering subevent = ' TRIGGER(SUBEVENT)) RETURN TRUE END DEFINE MYVAR VARIABLE TEXT
However, if you modified the program so that it returned
FALSE, then when you detach and reattach the workspace, not only would the
myvar definition not in the workspace, the definition for the TRIGGER_BEFORE_UPDATE program would also not be in the workspace.