如何绘制触发pl / sql触发器的行?

时间:2017-05-30 07:55:45

标签: oracle plsql triggers

这是我的代码:

CREATE  OR REPLACE  TRIGGER TR_DEL
AFTER INSERT OR UPDATE
ON DIZIONARIO_CHIAVI_DA_ESCLUDERE
FOR EACH ROW 
DECLARE
    CURSOR c_cursore_prendi_riga IS 
       SELECT CURRICULUM_CHIAVE_RICERCA 
         FROM PERSONA; 
    myCursor PERSONA.CURRICULUM_CHIAVE_RICERCA%TYPE; 
BEGIN
  OPEN c_cursore_prendi_riga;
  LOOP
    FETCH c_cursore_prendi_riga INTO myCursor;
    EXIT WHEN c_cursore_prendi_riga%NOTFOUND;
    dbms_output.put_line('oo='|| myCursor );

    -- Here I need it      

  END LOOP;
  CLOSE c_cursore_prendi_riga;
END;

我需要启动触发器的行,谢谢

1 个答案:

答案 0 :(得分:1)

尼古拉斯·克拉斯诺夫(Nicholas Krasnov)是对的,将其作为答案:

:new和:old用作伪记录。文档在这里:

https://docs.oracle.com/database/121/TDDDG/tdddg_triggers.htm#TDDDG50000

以及这些伪记录的解释:

https://docs.oracle.com/database/121/LNPLS/triggers.htm#LNPLS99955

最重要的是:伪记录不能像#34; normal"记录。你必须为每一列命名......

例如,你不能使用:

my_special_function(:new);

你必须创造一个真实的"记录:

declare
  myrec  mytable%rowtype;
begin
  myrec.id := :new.id;
  myrec.name := :new.name;
  myrec.birthdate := :new.birthdate;
  etc etc etc
  my_special_function(myrec);
end