-1

i have the following trigger that triggers an insertion on THAT_TABLE whenever there's an insertion or update to THIS_TABLE.

The following query works as is the way it should. Likewise-- it works when i comment line-A and uncomment (and remove or in) line-B.

    create or replace trigger t99 
    after  
    update -- line-A
    --or insert -- line-B
    on THIS_TABLE
    REFERENCING new as newRow
    for each row MODE DB2SQL
    insert into THAT_TABLE
        values  (newRow.tnumber, 'O', newRow.cocode, CURRENT TIMESTAMP, null, null)

However, i get the following error when i uncomment both lines:

An unexpected token "OR INSERT" was found following "". Expected tokens may include: "".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.21.29

What's missing?

I am running DB2 9.1 on Windows 10

chrki
  • 6,143
  • 6
  • 35
  • 55
user6401178
  • 183
  • 2
  • 11

1 Answers1

1

Try enclosing your statement in a BIGIN END block like in my example:

create table test.triggerevent (id int, text varchar(50))@
create table test.log (id int, text varchar(50), ts timestamp)@

create or replace trigger tlog
   after update or insert 
   on test.triggerevent
   referencing new as newRow
   for each row mode db2sql
   begin
     insert into test.log values (newRow.ID, newRow.text, current timestamp);
   end
   @
MichaelTiefenbacher
  • 3,805
  • 2
  • 11
  • 17