在oracle触发器中执行过程

问题描述 投票:0回答:1

我有一个不同的触发器,并且希望执行用于不同模式的过程以提取数据。

触发器中带有参数的执行过程不起作用。

create or replace TRIGGER TRIGER_LEAD_INSERT
  AFTER INSERT ON AT_NEO_CM.LEAD_INFORMATION 
    FOR EACH ROW
DECLARE 
  --PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN

  IF :new.LEAD_REFERENCE_NUMBER IS NOT NULL THEN    
      AT_NEO_CAS_LMS.PKG_LEAD_DATA.USP_INSERT_NEWAPP(:NEW.LEAD_REFERENCE_NUMBER,:NEW.ID );   
END IF;

  EXCEPTION 
    WHEN NO_DATA_FOUND THEN 

       INSERT INTO LEADDATA VALUES(  :NEW.ID, :NEW.LEAD_REFERENCE_NUMBER,2322, 'NO DATA FOUND');

END TRIGER_LEAD_INSERT;
oracle plsqldeveloper
1个回答
0
投票

要从另一个模式调用过程,您只需要设置正确的授予:

CREATE USER u1 IDENTIFIED BY u1 QUOTA 1M ON USERS;
CREATE USER u2 IDENTIFIED BY u2 QUOTA 1M ON USERS;
GRANT CONNECT, RESOURCE TO u1;
GRANT CONNECT, RESOURCE TO u2;

用户u1具有过程p1,并将其授予用户u2

CREATE PROCEDURE p1(p NUMBER) AS BEGIN NULL; END p1;
GRANT EXECUTE ON p1 TO u2;

用户u2现在可以执行此过程:

CONNECT u2/u2;
EXEC u1.p1(1);

或在触发器中使用它:

CREATE TABLE t2 (id NUMBER);

CREATE OR REPLACE TRIGGER tr2 AFTER INSERT ON t2
  FOR EACH ROW
BEGIN
  IF :new.id IS NOT NULL THEN    
    u1.p1(:new.id); 
  END IF; 
END tr2;
/
© www.soinside.com 2019 - 2024. All rights reserved.