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
Solved

How to create a schedule?

Posted on 2003-10-27
5
576 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
  • 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
There's a lot of hype surrounding blockchain technology. Here's how it works and some of the novel ways it' s now being used - including for data protection.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

860 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