Solved

How to create a schedule?

Posted on 2003-10-27
5
586 Views
Last Modified: 2008-02-01
I have a table - history
with PK - id, datetime - Lastaccessed

I want to create a sybase event that will automatically delete old history which are 7 days old that will run everyday.
how will i test this if this works?

i tried to use the wizzard but it doest work when i try to change the date&time.

btw, im using sybase ADAnywhere.

can you give me a script? and to test if it works. thanx
0
Comment
Question by:Jerry_Pang
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9631255
delete MyTable
where datediff( day, last_accessed, getdate() ) > 7

or

delete MyTable
where dateadd( day, 7, last_accessed ) < getdate()

HTH

Namasi Navaretnam

0
 
LVL 9

Author Comment

by:Jerry_Pang
ID: 9631778
i mean
howto,
create event eventname as {
everyday at 01:00

delete MyTable
where dateadd( day, 7, last_accessed ) < getdate()
}
0
 
LVL 15

Accepted Solution

by:
namasi_navaretnam earned 125 total points
ID: 9633277
Jerry,

CREATE EVENT DailyDelete
SCHEDULE DailyDelete
START TIME '1:00AM' EVERY 24 HOURS
HANDLER
   BEGIN
      delete MyTable
     where dateadd( day, 7, last_accessed ) < getdate()
   END

HTH
Namasi
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9655422
DId this help?
0
 
LVL 9

Author Comment

by:Jerry_Pang
ID: 9655580
yep. i forgot.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deploying our service is a grudge match between customer benefits and customer pain. In one corner, rolling out fixes (yay!) and delivering new features (double yay!). In the other corner, training on new features (boo – sounds like work), and chan…
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question