Declaring keywords of SQL as correlation names
- 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.)
CREATE TRIGGER t1 UPDATE OF b ON tab1 FOR EACH ROW (EXECUTE PROCEDURE p2() INTO delete, d);
- 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);