Re: Deleting with goup

From: Kenneth Herskedal <kenneth.herskedal_at_NOSPAMtrafsys.no>
Date: Sat, 21 Jul 2001 21:10:12 GMT
Message-ID: <9fl59o$dm9$1_at_oslo-nntp.eunet.no>


I'm using this script to delete rows. col_2 is a DATE type, so I delete the oldest rows first. (Script is not checked for syntax errors)

declare
 numb number; -- Number of rows
 dele number; -- Number of rows to be deleted  x number; -- Number of rows to save
 del_id number; - Unique ID of row to be deleted  i number;
 cursor c_log is select col_id from log order by col_2 asc; begin
 x := 12;
 select count(*) into numb from log;
 dele := ant - x;
 if ( dele > 0 ) then

  • Delete rows open c_log; for i in 1..sle loop fetch c_log into del_id; delete from log where col_id = del_id; end loop; close c_log; commit; end if; end;

Michal skrev i meldingen <3b1e0c6b_at_news.vogel.pl>...
>I need to delete some data from table
>but I must use HAVING COUNT(*)=x
>in the condition of delete. The delete syntax
>of course do not allow such one so I've tried to
>create view (with group by clause)
>and delete data from it
>but oracle says that this I cannot modify
>data within it. Any other views created on
>the same set of tables are of course udateable.
>
>Is there any other way to delete it?
>
>Thanks in advance
>--
>Michal
>
>
Received on Sat Jul 21 2001 - 23:10:12 CEST

Original text of this message