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