Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   SQL Statements > CREATE TRIGGER >

External Tables

The trigger action can affect tables of other database servers. The following example shows an Update trigger on dbserver1, which triggers an UPDATE to items on dbserver2:

CREATE TRIGGER upd_nt UPDATE ON newtab
   REFERENCING new AS post
   FOR EACH ROW(UPDATE stores_demo@dbserver2:items 
      SET quantity = post.qty WHERE stock_num = post.stock 
      AND manu_code = post.mc)

If, however, a statement from an external database server initiates a trigger whose action affects tables in an external database, the trigger actions fail.

For example, the following combination of trigger action and triggering statement results in an error when the triggering statement executes:

-- Trigger action from dbserver1 to dbserver3:

CREATE TRIGGER upd_nt UPDATE ON newtab
REFERENCING new AS post
FOR EACH ROW(UPDATE stores_demo@dbserver3:items 
   SET quantity = post.qty WHERE stock_num = post.stock 
   AND manu_code = post.mc);
-- Triggering statement from dbserver2:

UPDATE stores_demo@dbserver1:newtab 
   SET qty = qty * 2 WHERE s_num = 5 
   AND mc = 'ANZ'; 
Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]