text: --
  -- Copyright 2010-2017 Boxfuse GmbH
  --
  -- Licensed under the Apache License, Version 2.0 (the "License");
  -- you may not use this file except in compliance with the License.
  -- You may obtain a copy of the License at
  --
  --         http://www.apache.org/licenses/LICENSE-2.0
  --
  -- Unless required by applicable law or agreed to in writing, software
  -- distributed under the License is distributed on an "AS IS" BASIS,
  -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  -- See the License for the specific language governing permissions and
  -- limitations under the License.
  --
  
  CREATE TABLE TEST (
  ID INTEGER NOT NULL,
  NAME VARCHAR(128) NOT NULL,
  PRIMARY KEY (ID)
  );
  
  CREATE TABLE TEST_REFERENCE (
  REF_ID INTEGER NOT NULL,
  TEST_ID INTEGER NOT NULL,
  PRIMARY KEY (REF_ID),
  CONSTRAINT FK_TEST_ID FOREIGN KEY (TEST_ID) REFERENCES TEST (ID)
  );
  
  CREATE TRIGGER TRG_Del_Test AFTER DELETE ON TEST_REFERENCE
  REFERENCING OLD AS EXISTING
  FOR EACH ROW MODE DB2SQL
  DELETE FROM TEST
  WHERE ID = EXISTING.TEST_ID
  ;
  
  INSERT INTO TEST VALUES (1, 'Test trigger');
  INSERT INTO TEST_REFERENCE VALUES (1, 1);