Declaring keywords of SQL as correlation names

If you use the INSERT, DELETE, UPDATE, or EXECUTE keywords as a correlation identifier in any of the following clauses inside a triggered action list, you must qualify them by the owner name, the table name, or both:
  • FROM clause of a SELECT statement
  • INTO clause of the EXECUTE PROCEDURE or EXECUTE FUNCTION statement
  • GROUP BY clause
  • SET clause of the UPDATE statement.

The database server issues a syntax error if these keywords are not qualified when you include these clauses inside a triggered action.

If you use the keyword as a column name, it must be qualified by the table name; for example, table.update. If both the table name and the column name are keywords, they must be qualified by the owner name (for example, owner.insert.update). If the owner name, table name, and column name are all keywords, the owner name must be in quotation marks; for example, 'delete'.insert.update. (These are general rules regarding reserved words as identifiers, rather than special cases for triggers. Your code will be easier to read and to maintain if you avoid using the keywords of SQL as identifiers.)

The only exception is when these keywords are the first table or column name in the list, and you do not need to qualify them. For example, delete in the following statement does not need to be qualified because it is the first column listed in the INTO clause:
CREATE TRIGGER t1 UPDATE OF b ON tab1
   FOR EACH ROW (EXECUTE PROCEDURE p2() INTO delete, d);
The following statements show examples in which you must qualify the column name or the table name:
  • FROM clause of a SELECT statement
    CREATE TRIGGER t1 INSERT ON tab1
       BEFORE (INSERT INTO tab2 SELECT * FROM tab3, 'owner1'.update);
  • INTO clause of an EXECUTE PROCEDURE statement
    CREATE TRIGGER t3 UPDATE OF b ON tab1
       FOR EACH ROW (EXECUTE PROCEDURE p2() INTO
       d, tab1.delete);

    An INSTEAD OF trigger on a view cannot include the EXECUTE PROCEDURE INTO statement among its triggered actions.

  • GROUP BY clause of a SELECT statement
    CREATE TRIGGER t4 DELETE ON tab1
       BEFORE (INSERT INTO tab3 SELECT deptno, SUM(exp)
       FROM budget GROUP BY deptno, budget.update);
  • SET clause of an UPDATE statement
    CREATE TRIGGER t2 UPDATE OF a ON tab1
       BEFORE (UPDATE tab2 SET a = 10, tab2.insert = 5);