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 -> Help with cursor and fetch command!

Help with cursor and fetch command!

From: Josef Teepe <std6673_at_et.fh-osnabrueck.de>
Date: Mon, 18 May 1998 21:56:03 +0200
Message-ID: <35609253.87A3198F@et.fh-osnabrueck.de>


hello,

Please can you help me!!
I' m using oracle 7.3. I have two tables with the same columns. Table1 is getting datas from an interface six times an hour. I want to average this six rows to one row of an hour and insert this row to table2. When that is done table1 has to be deleted, so that in the future the table is not going to be too big.
Important is that that is done by the database itsself!! Can You help me to finishing my code. It is now only an SQL code, because i' m a beginner in PL/SQL.
code:
DECLARE cursor c_data IS
select avg(column1),

avg(column2),
avg(column3),
avg(column4),
avg(column5),
avg(column6),
avg(column7),
avg(column8),
avg(column9),
avg(column10),
avg(column11),
avg(column12),
avg(column13)

from josef.table1
WHERE rownum =6
ORDER BY date asc;
BEGIN
      OPEN c_data;
      LOOP
            FETCH c_data INTO josef.table2(column1, column2, column3,
    column4, column5, column6, column7,     column8, column9, column10, column11,     column12, column13);
  EXIT WHEN c_data%NOTFOUND;
  EXIT WHEN rownum=6;
  END LOOP;
  COMMIT;
EXCEPTION
END; Thanks in advance!!

Josef Received on Mon May 18 1998 - 14:56:03 CDT

Original text of this message

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