Louie
Louie

Reputation: 21

Learning about DB2 triggers

Hi I am trying to figure out the syntax for triggers. I have two tables one called tagged_in and the other notification. So I want to make a trigger where when an insert is called in tagged_in I want to insert a tuple in notification.

Upvotes: 0

Views: 325

Answers (2)

Aljaz Vidmar
Aljaz Vidmar

Reputation: 675

Something like this

CREATE TRIGGER TEST_TRIGGER
     AFTER INSERT ON TAGGED_IN
     REFERENCING NEW AS NEW_TAG
     FOR EACH ROW
     BEGIN ATOMIC
       INSERT INTO NOTIFICATION
         VALUES (NEW_TAG.FIELD1,NEW_TAG.FIELD2);
     END

Upvotes: 0

Jonathan Leffler
Jonathan Leffler

Reputation: 753930

The manuals are available at the DB2 InfoCenter. Did you read the CREATE TRIGGER statement information yet? If not, why not? If so, what did you try, and what error did you get?

Upvotes: 1

Related Questions