数据库触发器代码报错!急!在线等!

数据库触发器代码报错!急!在线等!,第1张

没有看到报错原因,不知道哪里错了,但是感觉语法都有问题,我给你看一个例子吧,你直接copy到PL/SQL中,看以来方便点

create or replace trigger C_PRIVILEGE_SYN_TRIG

after insert or delete or update on mes_frame_role_user

for each row

declare

-- local variables here

newuser varchar2(20)

newrole varchar2(20)

olduser varchar2(20)

begin

newuser := :new.emp_no

newrole := :new.roleid

olduser := :old.emp_no

case

when inserting then

--insert the new authority to the old system

insert into c_privilege(

select distinct newuser, '', mf.function, 2, mf.module

from mes_frame_role_authority ra

inner join mes_frame_menu m on ra.menuid = m.id

inner join mes_frame_menu m2 on m.tonode = m2.id

inner join c_module_fun_t mf on m.caption = mf.function and m2.caption = mf.module

where ra.roleid = newrole)

when updating then

delete c_privilege where emp = newuser

insert into c_privilege(

select distinct newuser, '', mf.function, 2, mf.module

from mes_frame_role_authority ra

inner join mes_frame_menu m on ra.menuid = m.id

inner join mes_frame_menu m2 on m.tonode = m2.id

inner join c_module_fun_t mf on m.caption = mf.function and m2.caption = mf.module

where ra.roleid = newrole)

when deleting then

delete c_privilege where emp = olduser

end case

end C_PRIVILEGE_SYN_TRIG

解决方法如下:

1)导入数据的用户不仅需要CREATE ROUTINE, ALTER ROUTINE, CREATE TRIGGER, ALTER TRIGGER,

CREATE FUNCTION 和 ALTER FUNCTION 权限,还需要SUPER privileges 权限,使用超级用户导入数据。

2)让所有用户具有执行类似functions的权限,危险,不推荐,

o by specifying it on the server start, like: –log-bin-trust-function-creators=1

o by setting it to 1 through the SET GLOBAL statement, like:

mysql>SET GLOBAL log_bin_trust_function_creators = 1

3)如果不需要复制,或者是从库,关闭binlog,

?

# binary logging – not required for slaves, but recommended

#log-bin=mysql-bin

# binary logging format – mixed recommended

#binlog_format=mixed


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/6722527.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-27
下一篇 2023-03-27

发表评论

登录后才能评论

评论列表(0条)

保存