如何为Oracle触发器授予从其他模式访问函数的权限

时间:2017-03-31 19:10:09

标签: oracle triggers

我遇到一个问题,我尝试从触发器调用函数。此功能来自不同的架构。我为触发器的用户授予访问权限的权限:

select 'GRANT EXECUTE ON VARTABLE.SEATS TO OWNER_OF_TRIGGER;' from all_objects where owner = 'xxx' and object_type='FUNCTION';

然而,这不起作用。这是不可能的,还是我需要将函数复制到触发器的模式中?

create or replace TRIGGER CALCULATOR 
AFTER INSERT ON PEOPLE
FOR EACH ROW
DECLARE
BEGIN
<<VARTABLE>> DECLARE
SEATS NUMBER;
INCOME NUMBER;
CANNOT_CHANGE_VALUE EXCEPTION;
  BEGIN
    SELECT COMPANY.SEAT(5,0.5,3.5) INTO VARTABLE.SEATS FROM DUAL;
    SELECT COMPANY.INCOME(3,360,500) INTO VARTABLE.INCOME FROM DUAL;
    IF INSERTING THEN
      INSERT INTO CALCULATIONS (cd_id,
      SITTING_PLACE,
      INCOME) VALUES (:NEW.CD_ID,
      VARTABLE.SEATS,
      VARTABLE.INCOME);
    END IF;
  END;
END;

1 个答案:

答案 0 :(得分:0)

有点回到我的甲骨文时代,但你应该能够创建一个同义词来处理这个链接。

https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7001.htm