触发器问题。。

Dream_1986 2010-11-10 05:08:47

create table emp_bak as select * from emp;

create table emp_log(
who varchar2(30),
when date,
action varchar2(20)
);
Create or replace trigger biud_emp_copy
Before insert or update or delete On emp_bak
Declare
l_action emp_log.action%type;
Begin
if inserting then
l_action := 'Insert';
elsif updating then
l_action := 'Update';
elsif deleting then
l_action := 'Delete';
else
raise_application_error(-20001,
'You should never ever get this error.');
Insert into emp_log
(Who, action, when)
Values
(user, l_action, sysdate);
End if;
end;
insert into emp_bak( EMPNO, ENAME, JOB, HIREDATE, SAL)
values(20,'song','Manager',sysdate,20000);

--insert into 或者update操作后发现emp_log表中action字段没有内容,哪里有问题?

谢~~~~~
...全文
53 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
minitoy 2010-11-10
  • 打赏
  • 举报
回复
接分
YY_MM_DD 2010-11-10
  • 打赏
  • 举报
回复
嘿嘿。。。当我没说
YY_MM_DD 2010-11-10
  • 打赏
  • 举报
回复
你的插入语句提交没有?
gelyon 2010-11-10
  • 打赏
  • 举报
回复
你insert emp_log 位置错了,放到end if 外面 ,你是当有异常时候才insert的
Dream_1986 2010-11-10
  • 打赏
  • 举报
回复
明白了。。。o(╯□╰)o

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧