Automatic Delete

Results 1 to 2 of 2

Thread: Automatic Delete

  1. #1
    Join Date
    Dec 1969

    Default Automatic Delete

    How can I have entries say for example older than 30 days from the current date be automaticaly deleted from the database or have the status database field for example updated to "archived" from "current"?

  2. #2
    Join Date
    Dec 1969

    Default You could schedule a task... do this. Assuming you are allowed to schedule tasks on the server machine.<BR><BR>But a simple way would be to write code so that the first time a specific ASP page is "hit" each day then it does the update (or delete) for you.<BR><BR>Let&#039;s see...<BR><BR>&#060;%<BR>needUpdate = False<BR>Application.Lock<BR>lastUpdate = Application("LastUpdate")<BR>If "" & lastUpdate = "" Then <BR> needUpdate = True<BR>Elseif lastUpdate &#060; Date() Then <BR> needUpdate = True<BR>End If <BR>Application("LastUpdate") = Date()<BR>Application.Unlock<BR><BR>If needUpdate Then<BR> SQL = "UPDATE table SET [status] = &#039;archived&#039; " _<BR> & " WHERE [status] = &#039;current&#039; " _<BR> & " AND [datefield] &#060; Date()-30 "<BR> conn.Execute SQL<BR>End If<BR>%&#062;<BR><BR>That SQL is for Access. Needs minor mods for other DBs.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts