Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Triggers to update same column upon insert

Re: Triggers to update same column upon insert

From: <ctcgag_at_hotmail.com>
Date: 18 Apr 2003 01:00:57 GMT
Message-ID: <20030417210057.387$l6@newsreader.com>


Sanjay Kumar <skumar_at_nospam.com> wrote:
> I am new to Oracle.
>
> Ver 8.1.7
>
> Is it possible to declare a trigger to update the same
> column which is being inserted upon.
>
> For e.g.,
>
> insert into table_a(field_a) values(1);
>
> and then declare a trigger on table_a which will update the value
> of field_a to field_a + 100. In effect all values of field_a gets
> incremented by 100 automatically after every insert.

It's not clear what you are asking, to add 100 to just the field_a of the row being inserted, or to add 100 to all the field_a of all rows of the table everytime a row is inserted. In the first case, you just put ":new.field_a:=:new.field_a+100;" in a before trigger.

In the second case, don't.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB
Received on Thu Apr 17 2003 - 20:00:57 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US