By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,850 Members | 1,771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,850 IT Pros & Developers. It's quick & easy.

Help with Oracle to DB2 trigger translation

P: n/a
I'm new to DB2 and our team is in the process of
migrating from Oracle to DB2.

Assuming new.created_date is now a TIMESTAMP,
what would be the DB2 translation of this Oracle
trigger?

Thanks.

CREATE OR REPLACE TRIGGER "BZ".atable_created_date
BEFORE INSERT ON atable
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
BEGIN
SELECT sysdate INTO :new.created_date
FROM DUAL;
END;
/

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
gi*******************@yahoo.com wrote:
I'm new to DB2 and our team is in the process of
migrating from Oracle to DB2.

Assuming new.created_date is now a TIMESTAMP,
what would be the DB2 translation of this Oracle
trigger?

Thanks.

CREATE OR REPLACE TRIGGER "BZ".atable_created_date
BEFORE INSERT ON atable
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
BEGIN
SELECT sysdate INTO :new.created_date
FROM DUAL;
END;
/

CREATE TRIGGER "BZ".atable_created_date
BEFORE INSERT ON atable
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN ATOMIC
SET NEW.created_date = CURRENT DATE;
END
@

If you are on a version prior to DB2 V8.2 you need to use:
_NO_CASCADE_ BEFORE and also add _MODE_DB2SQL_ after FOR EACH ROW

Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.