dbTalk Databases Forums  

Oracle trigger

comp.database.oracle comp.database.oracle


Discuss Oracle trigger in the comp.database.oracle forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
tg
 
Posts: n/a

Default Oracle trigger - 11-23-2004 , 03:43 PM







I would appreciate some help constructing a trigger. I'm not familiar with
the Oracle syntax, and I haven't been able to find what I need online.

Suppose there is a column in a table that is named COLA2. In this column, I
want to enter the value of column COLA (a number column) + 1.

What is the syntax for such a trigger?

thanks
tg



Reply With Quote
  #2  
Old   
Hilarion
 
Posts: n/a

Default Re: Oracle trigger - 11-24-2004 , 08:03 AM






In Oracle 8i (schema_name1 can be and in most cases should be equal to schema_name2,
ommiting means current schema):

CREATE [OR REPLACE] TRIGGER [schema_name1.]trigger_name
BEFORE INSERT OR UPDATE
ON [schema_name2.]table_name
BEGIN
:NEW.COLA2 := :NEW.COLA + 1;
END;

If you are using something like "SQL Plus", then you'll have to add backslash
after the code (in new line).

Hilarion



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.