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: Newbie needs help

Re: Newbie needs help

From: <RTProffitt_at_beckman.com>
Date: Fri, 07 May 1999 19:08:43 GMT
Message-ID: <7gvdnm$p4k$1@nnrp1.deja.com>


I suspect there is a problem in the continuity of sequence number or the relationship of p_len to sequence number.

  1. is P_len in units of P-Seq_no, since you do a P-seq_len minus p_len.
  2. Can you guarantee the p_seq_no is sequential and that none are missing? If Seq_no comes from a sequence generator, then you cannot guarantee this.
  3. Does seq_no always increase over time? Assuming this is true, then you can write a function

P-len becomes the size of the moving average, as in "the last 35 items": p_len=35 p_seq_no becomes the starting seq_no, assumes you want this flexibility to start at any point.

Sort the data descending, then gather n data points and average them.

Function awt_ma (etc,...) Return NUMBER IS

Cursor cGetData is

   select close
   from awt_stock_price
   where symbol=p_symbol
   and seq_no <= p_seq_no
   order by p_seq_no DESC ;

totcnt number := 0;
wrkTot number := 0;
wrkClose number := 0;
Begin
open cGetData;

For i IN 1..p_len LOOP
  Fetch cGetData into wrkClose;
  Exit When cGetData%NOTFOUND;

  If Close is not null Then

     tot := tot + 1;
    wrkTot := wrkTot + wrkClose;
  End If;

End Loop;

END; Robert Proffitt
Beckman/Coulter
RTProffitt_at_Beckman.Com

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Fri May 07 1999 - 14:08:43 CDT

Original text of this message

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