473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Help with Oracle to DB2 trigger translation

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
1 1581
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: gimme_this_gimme_that | last post by:
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....
2
by: Ken | last post by:
I got an Access database that need to be converted to Oracle 9i. Somehow the Trigger we created to simulate the "AUTO NUMBER" on Access could not create the sequence number as soon as the value has...
4
by: dhcomcast | last post by:
We're starting to use Oracle for the back-end instead of a separate Access .mdb file for the data and everything as gone surprisingly well so far. We are learning Oracle as we go; Yikes! But we...
7
by: peter.morin | last post by:
Issue: I am inserting an Oracle record containing insert trigger via Access 2002 using the code below. The issue is that the sequence from the acSaveRecord is not reflected after the insert so...
0
by: gshawn3 | last post by:
Hi, I am having a hard time creating a Trigger to update an Oracle database. I am using a SQL Server 2005 Express database on a Win XP Pro SP2 desktop, linked to an Oracle 10g database on a...
4
by: Alexis | last post by:
Hello, I'm facing oracle trigger problem. Anyone can help or advise how to resolve it? Below are the explaination on my problem I've created a trigger for my program. When there is a new...
2
by: Vinod Sadanandan | last post by:
All, Below listed are the new features in Oracle 11g ,please join me in this discussion to generate a testcase and analyze each of the listed features . Precompilers:...
11
by: tracy | last post by:
Hi, I really need help. I run this script and error message appeal as below: drop trigger log_errors_trig; drop trigger log_errors_trig ERROR at line 1: ORA04080: trigger 'LOG_ERRORS-TRIG'...
2
by: singhjih | last post by:
The table looks like the following: Code ------------------- INSTRUCTOR_ID(PK) NUMBER(8,0) NOT NULL SALUTATION VARCHAR2(5) NULL FIRST_NAME VARCHAR2(25) NULL LAST_NAME ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.