Converting IBM DB2 TRIGGERs to PostgreSQL - Mailing list pgsql-novice

From Alan Searles
Subject Converting IBM DB2 TRIGGERs to PostgreSQL
Date
Msg-id 1055293396.1087.34.camel@aurora
Whole thread Raw
Responses Re: Converting IBM DB2 TRIGGERs to PostgreSQL
List pgsql-novice
I am relatively new to PostgreSQL, and I am currently trying to convert
a JAVA application that currently runs under IBM's DB2.

Part of my challenge is to somehow convert the following (sample)
TRIGGER statements that work just fine under DB2.

------------------------------------------------------------------------------------------------
CREATE TRIGGER ALIEN.COUNTRY_INS
         AFTER INSERT ON ALIEN.COUNTRY
         REFERENCING NEW AS X
         FOR EACH ROW MODE DB2SQL
         BEGIN ATOMIC
           INSERT INTO ALIEN.COUNTRY_LOG
                  VALUES (X.COUNTRYID, X.FULLNAME, X.CODE,
                          X.UNDEFINED, X.MARKFORDELETE, X.USERID,
                          CURRENT TIMESTAMP, CURRENT TIMESTAMP, 'INS');
         END

CREATE TRIGGER ALIEN.COUNTRY_UPD
         AFTER UPDATE ON ALIEN.COUNTRY
         REFERENCING NEW AS X
         FOR EACH ROW MODE DB2SQL
         BEGIN ATOMIC
           INSERT INTO ALIEN.COUNTRY_LOG
                  VALUES (X.COUNTRYID, X.FULLNAME, X.CODE,
                          X.UNDEFINED, X.MARKFORDELETE, X.USERID,
                          CREATED, CURRENT TIMESTAMP, 'UPD');
         END

------------------------------------------------------------------------------------------------
Can this be done with PostgreSQL ?  I am concerned more with the "BEGIN
ATOMIC" sections.

Any help would be appreciated. Thanks.

/Alan


pgsql-novice by date:

Previous
From: Tom Lane
Date:
Subject: Re: join and where clause equivalent ?
Next
From: Josh Berkus
Date:
Subject: Re: Converting IBM DB2 TRIGGERs to PostgreSQL