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 -> Using the Avg() function

Using the Avg() function

From: Jeff Boyer <jdboyer_at_icomproductions.ca>
Date: Thu, 6 Sep 2001 11:26:25 -0600
Message-ID: <9n8bnm$nbr$1@news3.cadvision.com>


I understand how to use the Avg() function but how would I go about using it in a trigger so that when a column is updated it calculates the average of that column but only for the records with the same primary key ans the record being updated. This is what I have for a trigger so far:

CREATE OR REPLACE TRIGGER Score
 BEFORE INSERT on Phase2_5Ans
 FOR EACH ROW
 DECLARE
      Temp varchar2(30);
 BEGIN

      Select Avg(Score) from Phase2_5Ans where ??? into temp from dual;
      :New.TotalScore := Temp;

 End;
/

Can anyone help me?? I know there is a simple solution to my problem I just don't know how to pass a variable to the where clause.

Thanks again,
Jeff Received on Thu Sep 06 2001 - 12:26:25 CDT

Original text of this message

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