Derby
  1. Derby
  2. DERBY-172

Improve documentation for BEFORE triggers

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 10.0.2.0
    • Fix Version/s: None
    • Component/s: Documentation
    • Environment:
      Windows XP SP1 Windows
    • Urgency:
      Low

      Description

      I image that this is a documentation problem. The "words" around triggers seem to imply the ability to do actions "BEFORE" the INSERT/UPDATE/DELETE. For instance:

      "Along with constraints, triggers can help enforce data integrity rules with actions such as cascading deletes or updates. Triggers can also perform a variety of functions such as issuing alerts, updating other tables, sending e-mail, and other useful actions."

      Well, the CREATE TRIGGER command only allows AFTER as an option (even though the SYSTRIGGERS catalog uses "B" for before and "A" for after) and it won't allow a CALL statement to be processed. Seems to me that there aren't any ways to send an e-mail, issue alerts (no SIGNAL function either), or enforce integrity rules. How can you enforce integrity rules if invalid data comes in? I can't force a SIGNAL or error with the trigger, so this is useless for validating changes to the data.

      In addition, there appears to be some logic regarding BEFORE triggers in Derby, but its not currently working.

      CREATE TRIGGER CB NO CASCADE BEFORE
      INSERT ON BONUSES
      REFERENCING NEW AS n
      FOR EACH ROW MODE DB2SQL
      UPDATE BONUSES
      SET BONUS =
      CASE
      WHEN (n.BONUS = 0) THEN 100
      ELSE n.BONUS
      END;
      ERROR 42Z9D: 'UPDATE' statements are not allowed in 'BEFORE' triggers.

        Activity

        Hide
        Mamta A. Satoor added a comment -

        really old jira with no activity in few years

        Show
        Mamta A. Satoor added a comment - really old jira with no activity in few years
        Hide
        Kathey Marsden added a comment -

        Changing title to better reflect the user request for better documentation for BEFORE triggers.

        Show
        Kathey Marsden added a comment - Changing title to better reflect the user request for better documentation for BEFORE triggers.
        Hide
        George Baklarz added a comment -

        Do you happen to know the syntax for the BEFORE trigger? I'd like to see if I can use it in an application.

        Show
        George Baklarz added a comment - Do you happen to know the syntax for the BEFORE trigger? I'd like to see if I can use it in an application.
        Hide
        Daniel John Debrunner added a comment -

        BEFORE triggers do work but they have the restriction that the trigger action must be read-only, that is a SELECT statement or a VALUES claues. The action statement can call a user defined Java function that could send e-mail or perform validation.

        Enabling the before triggers was last minute item before the code was contributed.

        Show
        Daniel John Debrunner added a comment - BEFORE triggers do work but they have the restriction that the trigger action must be read-only, that is a SELECT statement or a VALUES claues. The action statement can call a user defined Java function that could send e-mail or perform validation. Enabling the before triggers was last minute item before the code was contributed.

          People

          • Assignee:
            Unassigned
            Reporter:
            George Baklarz
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development