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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to write this Trigger ?

Re: How to write this Trigger ?

From: <michael_bialik_at_my-deja.com>
Date: Wed, 03 Nov 1999 21:20:23 GMT
Message-ID: <7vq8uh$fap$1@nnrp1.deja.com>


Hi.

 You are wright - the statement level trigger will solve the "mutating  table" problem - but it will introduce a new one :  Performance will suffer - because FULL table scan will be executed  each time ( unless the table is very small ).  I suggest to create another table and use FOR EACH ROW trigger  to compute the SUM.
 Make a join to that table to display the result.

 HTH. Michael.

In article <7vphkf$b7h$1_at_oceanite.cybercable.fr>,   "Michel Cadot" <micadot_at_netcourrier.com> wrote:
> Why don't you just use an after insert trigger NOT for each row?
>
> --
> Have a nice day
> Michel
>
> <wy_at_fudan.edu> a écrit dans le message :
7vpg9b$s8o$1_at_nnrp1.deja.com...
> > I have a table t1.
> > Create table t1(
> > CostName Char(10),
> > Cost Number(12,2) default 0,
> > AllCost Number(12,2) default 0
> > );
> > I Want to use Trigger to set AllCost = sum(Cost) by CostName.
> > I use "after insert for each row" and get mutating error!
> >
> > How to write this trigger!
> > or some better ways to realise this function.
> >
> > eg:
> > Insert 'abc',1
> > the result 'abc',1,1
> > insert 'abc',2
> > the result 'abc',1,3
> > 'abc',2,3
> > insert 'abc',1
> > the result 'abc',1,4
> > 'abc',2,4
> > 'abc',1,4
> >
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Wed Nov 03 1999 - 15:20:23 CST

Original text of this message

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