一个简单的触发器问题
时间:2011-11-09
来源:互联网
我要用触发器实现每天下班时间不能访问表:
create or replace trigger hospital14_dui
before insert or update or delete on hospital14
declare
v_time varchar2(20);
begin
v_time:=to_char(sysdate,'hh24:mi:ss');
if (v_time>17:00:00 or v_time<8:00:00)
then
raise_application_error(-2000,'a table can not be modified');
end if;
end;
结果编译出错,是不是 if (v_time>17:00:00 or v_time<8:00:00)
这句写错了?该怎么改呢?
create or replace trigger hospital14_dui
before insert or update or delete on hospital14
declare
v_time varchar2(20);
begin
v_time:=to_char(sysdate,'hh24:mi:ss');
if (v_time>17:00:00 or v_time<8:00:00)
then
raise_application_error(-2000,'a table can not be modified');
end if;
end;
结果编译出错,是不是 if (v_time>17:00:00 or v_time<8:00:00)
这句写错了?该怎么改呢?
作者: zhoulirong14 发布时间: 2011-11-09
if (v_time>'17:00:00' or v_time<'8:00:00')
作者: yixilan 发布时间: 2011-11-09
就是这句写错了if (v_time>17:00:00 or v_time<8:00:00)
还有一个地方,错误号码范围不对,自定义错误只能用-20001~-20999之间的数字
create or replace trigger hospital14_dui
before insert or update or delete on hospital14
declare
v_time varchar2(20);
begin
v_time:=to_char(sysdate,'hh24:mi:ss');
if (v_time>'17:00:00' or v_time<'8:00:00')
then
raise_application_error(-20001,'a table can not be modified');
end if;
end;
还有一个地方,错误号码范围不对,自定义错误只能用-20001~-20999之间的数字
create or replace trigger hospital14_dui
before insert or update or delete on hospital14
declare
v_time varchar2(20);
begin
v_time:=to_char(sysdate,'hh24:mi:ss');
if (v_time>'17:00:00' or v_time<'8:00:00')
then
raise_application_error(-20001,'a table can not be modified');
end if;
end;
作者: tx2730 发布时间: 2011-11-09
[code=SQL][/code]create or replace trigger hospital14_dui
before insert or update or delete on hospital14
declare
v_time varchar2(20);
begin
v_time:=to_char(sysdate,'hh24:mi:ss');
if (v_time>'17:00:00' or v_time<'8:00:00')
then
raise_application_error(-2000,'a table can not be modified');
end if;
end
少了引号。
before insert or update or delete on hospital14
declare
v_time varchar2(20);
begin
v_time:=to_char(sysdate,'hh24:mi:ss');
if (v_time>'17:00:00' or v_time<'8:00:00')
then
raise_application_error(-2000,'a table can not be modified');
end if;
end
少了引号。
作者: jg_huang 发布时间: 2011-11-09
引用 1 楼 yixilan 的回复:
if (v_time>'17:00:00' or v_time<'8:00:00')
if (v_time>'17:00:00' or v_time<'8:00:00')
谢谢,晕啊!好糊涂的我
作者: zhoulirong14 发布时间: 2011-11-09
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28