SQL Anywhere 11 - 检查事件是否存在 [英] SQL Anywhere 11 - Check if event exists

查看:68
本文介绍了SQL Anywhere 11 - 检查事件是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个创建预定事件的 SQL 脚本:

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?

推荐答案

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

这篇关于SQL Anywhere 11 - 检查事件是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆