SQL Anywhere 11 - Check if event exists

六眼飞鱼酱① 提交于 2019-12-24 04:25:06

问题


I have an SQL script which creates a scheduled event:

CREATE EVENT "Daily_1200PM"
SCHEDULE "Daily_1200PM" START TIME '12:00' EVERY 24 HOURS
HANDLER
begin 
   -- Blah blah, do some stuff here
end;

I would like to remove this event, if it exists. I know I can remove the event with the following:

DROP EVENT "Daily_1200PM"

But for some databases, the the event doesn't actually exist, so an error is thrown.

How do I delete the event only if it exists?


回答1:


if exists( select * from sys.sysevent where event_name='Daily_1200PM' ) then
    drop event Daily_1200PM;
end if


来源:https://stackoverflow.com/questions/11263680/sql-anywhere-11-check-if-event-exists

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!