Previous
Previous
 
Next
Next

Creating an Object Trigger Program

Once an object is defined in an analytic workspace, you can create a trigger program for that object by following the following procedure:

  1. Define the program as described in DEFINE PROGRAM.

  2. Determine what to name the program and whether the program can be a user-defined program. (See Table: Object Trigger Program Characteristics.) If the program can be a user-defined program, decide whether or not you want to define the trigger program as a user-defined function.

  3. Code the actual program as described in"Specifying Program Contents".

  4. Keep the following points in mind when coding trigger programs:

    • Use Table: Object Trigger Program Characteristics to determine if Oracle OLAP passes values to the program. If it does, use an ARGUMENT statement to declare these arguments in your program and the VARIABLE statement to define program variables for the values. (See Table: Arguments Passed to Trigger Programs for specific information about the arguments.)

    • A program that is triggered by an Assign event is executed each time Oracle OLAP assigns a value to the object for which the event was defined. Thus, a program triggered by an Assign event is often executed over and over again as the assignment statements loops through a object assigning values. You can use TRIGGERASSIGN to assign a value that is different from the value specified by the assignment statement that triggered the execution of the program.

    • In some cases, Oracle OLAP changes the status of the dimension being maintained when a Maintain event triggers the execution of a program. See Table: How Programs Triggered by Maintain Events Effect Dimension Status for details

    • Use the CALLTYPE function within a program to identify that the program was invoked as a trigger.

  5. When the trigger program is not a TRIGGER_AFTER_UPDATE, TRIGGER_BEFORE_UPDATE, or TRIGGER_DEFINE program, associate the program with the desired object and event using the TRIGGER command.

  6. There is no support for recursive triggers. You must set the USETRIGGERS option to NO before you issue the same DML statement within a trigger program that triggered the program itself. For example, assume that you have written a program named TRIGGER_MAINTAIN_ADD that is triggered by MAINTAIN ADD statements. Within the TRIGGER_MAINTAIN_ADD program, you must set the USETRIGGERS option to NO before you issue a MAINTAIN statement.