Oracle® OLAP DML Reference 10g Release 2 (10.2) Part Number B14346-03 |
|
|
View PDF |
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 ofTRUE
for a TRIGGER_BEFORE_UPDATE program to executeSee also:
"Trigger Programs".Return Value
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 TRUE
or NA
, the UPDATE statement executes.
Syntax
To create a program with the name TRIGGER_UPDATE
, follow the guidelines presented in"Trigger Programs".
Examples
Example 26-12 TRIGGER_BEFORE_UPDATE Program
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 myva
r 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 myva
r definition not in the workspace, the definition for the TRIGGER_BEFORE_UPDATE program would also not be in the workspace.