Progress
Database Design
Guide


Trigger Types

There are two types of Java triggers provided: statement and row.

Statement triggers are tied to the SQL-92 statement boundaries. These triggers are only observed through the SQL-92 interface. Row triggers are fired when database events occur regardless of the interface to the database.

EXAMPLE

The following code illustrates an example of a statement trigger:

CREATE TRIGGER trig1 BEFORE DELETE ON customer
FOR EACH STATEMENT
BEGIN
   SQLIStatement upd_stmt 
     (“UPDATE summary SET trans_tot = trans_tot + 1");
   upd_stmt.execute ();
END 

NOTE: The UPDATE statement executes only once regardless of how many rows are deleted.

EXAMPLE

The following code examples illustrates a row trigger:

CREATE TRIGGER trig1 
BEFORE INSERT ON customer REFERENCING NEWROW
FOR EACH ROW
BEGIN
  String new_name; Integer new_num;
  new_num = (Integer) NEWROW.getValue(1,INTEGER);
  new_name = (String) NEWROW.getValue(2,INTEGER);
  SQLIStatement ins_stmt (“INSERT INTO customer2 (?,?,?,?,?,?) “);
  “UPDATE summary SET trans_tot = trans_tot + 1");
  ins_stmt.setParam (1, new_num);  ...
  ins_stmt.execute ();
END 

NOTES


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095