RDOHELP72.HLB  —  DEFINE_TRIGGER, Format
  (B)0DEFINE TRIGGER q> name wqqqqqqqqqqqqqq>qqqqqqqqqqqqqwwq> BEFORE wk
                         m> DESCRIPTION IS /* text */ jmq> AFTER qjx
  lqqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
  mw> STORE qqqqqqqqqqqqqqqqqqq>qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqwk
   t> ERASE qqqqqqqqqqqqqqqqqqq>qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqux
   m> MODIFY wqqqqqqqqqq>qqqqqqqqqqwwqqqqqqqqqqqqqq>qqqqqqqqqqqqwqjx
             m> OF qw> field-name wjm> context-variable-clause qj  x
                    mqqqqq , <qqqqj                                x
  lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
  m> FOR context-var IN relation-name w> triggered-action-clause w> .
                                      mqqqqqqqqqqqqqq<qqqqqqqqqqqj

1  –  name

    The name of the trigger that you can refer to in other
    statements. Use a name that is unique among all trigger names.

2  –  text

    A text string that adds a comment to the trigger definition.

3  –  field-name

    The name of a field within the specified relation to be checked
    for modification. You can specify a list of field names separated
    by commas. You can also specify all the fields in a relation by
    specifying the asterisk (*) wildcard character.

    Be sure that you specify ONLY those fields whose data values are
    to be changed. See the subtopic More for more information.

3.1  –  More

    In a BEFORE MODIFY or AFTER MODIFY trigger, be sure that you
    specify only the names of fields whose data values are to be
    changed, to avoid potentially unnecessary actions such as:

    o  Overlaying the data with itself within a record.

    o  Writing to the database (even though none of the fields in the
       record has actually changed values)

    o  Evaluating constraints that apply to fields in the MODIFY
       field list which have not changed values

    o  Evaluating MODIFY triggers that apply to fields in the MODIFY
       field list that have not changed values.

    o  Evaluating RDO VALID IF clauses for fields in the MODIFY field
       list that have not changed values.

    If there is a possibility that any of the fields in a MODIFY
    field list will not actually be changed, the triggered actions
    for any pertinent MODIFY triggers should be changed accordingly.

    For those cases in which a triggered action performs an operation
    based on the changed value for a particular field, the action
    should include a conditional expression that prevents execution
    of the operation if no value change occurs. The conditional
    expression, which compares the old value with the new value,
    should appear as part of the triggered action's WITH clause.

4  –  context-var-clause

  (B)0context-variable-clause =
  qqwqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqwq>
    tq> OLD CONTEXT old-context-var qu
    mq> NEW CONTEXT new-context-var qj

    An optional clause that can contain aliases for old and new
    states of the context variable of the triggering statement.

4.1  –  old-context-var

    A temporary name used to refer to the record values as they
    existed before a modify operation occurred. You use an old-
    context-var only when the trigger occurs after a modify
    operation, and must be a different name than the one given for
    context_var.

4.2  –  new-context-var

    A temporary name used to reference the new record values about
    to be applied by modify operation. You use a new-context-var only
    when the trigger occurs before a modify operation, and must be a
    different name than the one given for context-var.

5  –  context-var

    A temporary name defining the relation on which the trigger is
    defined. The context variable name is an alias for the record
    stream context of the triggering statement which has caused this
    trigger to be executed.

6  –  relation-name

    The name of the relation for which this trigger is defined
    (subject relation).

7  –  triggered-action-clause

  (B)0triggered-action-clause =

  qwqqqqqqqqqqqq>qqqqqqqqqqqqqqwqk
   mq> WITH conditional-expr qqj x
   lqqqqqqqqqqqqq<qqqqqqqqqqqqqqqj
   mq> EXECUTE qw> triggered-statement qwqqwqqqqqqqqqq>qqqqqqqqwq>
                mqqqqqqqqqqq ; qqqq<qqqqj  mq> FOR EACH RECORD j

  (B)0triggered-statement =

  qwq> store-statement qqqqqqqqqqqqqqqqqqqwq>
   tq> FOR rse store-statement END_FOR  qqu
   tq> FOR rse erase-statement END_FOR  qqu
   tq> FOR rse modify-statement END_FOR qqu
   mq> ERROR qqqqqqqqqqqqqqqqqqqqqqqqqqqqqj

    A triggered action clause consists of a conditional expression
    (optional), one or more triggered statements, and a frequency
    clause (FOR EACH RECORD). The EXECUTE keyword precedes the
    triggered action clause.

7.1  –  rse

    A record selection expression that defines which records of which
    relations will be affected by the triggered update action. This
    rse cannot refer to any host variables.

7.2  –  store-statement

    A STORE statement to be initiated by the trigger.

7.3  –  erase-statement

    An ERASE statement to be initiated by the trigger.

7.4  –  modify-statement

    A MODIFY statement to be initiated by the trigger.

7.5  –  WITH

    A conditional expression that describes the optional condition
    that must be satisfied before the associated triggered statements
    are executed. This expression cannot refer to any host variables.
    For more information on Oracle Rdb conditional expressions, ask for
    HELP on the top level topic Cond_expr.

7.6  –  FOR_EACH_RECORD

    A frequency clause, FOR EACH RECORD (no underscores), determines
    whether an action is evaluated once per triggering statement, or
    for each record of the subject relation updated by the triggering
    statement. If the FOR EACH RECORD clause is not specified, the
    triggered action is evaluated only once, and record values are
    not available to the triggered action.
Close Help