Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Deleting Old Files in a DB.

by benn (Priest)
on Oct 09, 2003 at 11:41 UTC ( #297880=note: print w/ replies, xml ) Need Help??

in reply to Deleting Old Files in a DB.

If you're looking for a way of deleting old *records* from an SQL-based DBMS, then you can usually do this with pure SQL (and thus in any language you like that provides DB connections), assuming that you stored the original record-creation time (rec_timestamp, in the example below).

Therefore, a simple Perl program to do this with MYSQL would look something like...

use DBI; my $dbh = DBI->connect("DBI:mysql:db_name","user","pass") || die $DBI: +:err; $dbh->do("delete from mytable where to_days(rec_timestamp) < to_days(n +ow()) - 90");
HTH, Ben.

Comment on Re: Deleting Old Files in a DB.
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://297880]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2015-11-26 00:22 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (693 votes), past polls