List:MaxDB« Previous MessageNext Message »
From:Elke Zabach Date:July 30 2003 6:04am
Subject:RE: sapdb 7.3 install error.
View as plain text  
John Franklin wrote:
> 
...
> I have another question? Is there a easy way to delete the 
> oldest 5 records
> from a table in SAPDB? When the number of records in a table exceeds a
> threshold I want to remove the oldest ones.

in pure SQL I would say:

DECLARE curs CURSOR FOR
SELECT .. FROM my_table
ORDER BY <that column which has the knowledge of age of record>
FOR UPDATE

loop for <number of oldest records to be deleted>
  FETCH curs INTO <parameter, which are of no use>
  DELETE my_table WHERE CURRENT OF curs


In ODBC there are options to tell a resultset to be updateable
and then the loop can be done


Or if you know the oldest age you want to store:
DELETE my_table 
WHERE <that column which has the knowledge of age of record> 
   <   <the first date you want to have in your table>


Elke
SAP Labs Berlin

Thread
sapdb 7.3 install error.John Franklin23 Jul
RE: sapdb 7.3 install error.John Franklin29 Jul
RE: sapdb 7.3 install error.Elke Zabach30 Jul
AW: sapdb 7.3 install error.Jan Lolling30 Jul