1

为了解决变异表错误,我关注了http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/triggers.htm#LNPLS2005,但它仍然无法正常工作。可以帮助确定以下触发器的问题在哪里吗?

谢谢,

CREATE OR REPLACE TRIGGER trg_d_inq_2 FOR
UPDATE OF hu1_dimension_lvl1
ON d_inq_dimensions
COMPOUND TRIGGER
v_exists_d NUMBER;
v_exists_c NUMBER;

TYPE process_t IS TABLE OF d_inq_dimensions.dimension_value%TYPE;

process process_t;

TYPE process_pvoc_t IS TABLE OF NUMBER
    INDEX BY VARCHAR2(100 BYTE);

process_pvoc process_pvoc_t;

TYPE nprocessvoc_t IS TABLE OF NUMBER;

nprocessvoc nprocessvoc_t;
BEFORE EACH ROW
IS
BEGIN
    SELECT a.hu1_dimension_lvl1, COUNT(a.hu1_dimension_lvl1)
      BULK COLLECT INTO process, nprocessvoc
      FROM d_inq_dimensions a
     WHERE a.dimension_name = 'Processo'
    GROUP BY a.hu1_dimension_lvl1;

    FOR j IN 1 .. process.COUNT
    LOOP
        process_pvoc(process(j)) := nprocessvoc(j);
    END LOOP;
END
BEFORE EACH ROW;

AFTER EACH ROW
IS
BEGIN
    IF :new.hu1_dimension_lvl1 IS NOT NULL AND
       :new.dimension_name = 'Processo'
    THEN
        IF process_pvoc(:old.hu1_dimension_lvl1) IS NULL
        THEN
            DELETE external.c_parameters
             WHERE proj_id = 79 AND
                   ind_id = 53 AND
                   lvl_2 = :old.hu1_dimension_lvl1;
        END IF;

        SELECT COUNT(1)
          INTO v_exists_c
          FROM external.c_parameters a
         WHERE proj_id = 79 AND
               ind_id = 53 AND
               lvl_2 = :new.hu1_dimension_lvl1;

        IF v_exists_c = 0
        THEN
            INSERT INTO external.c_parameters
            /*and something more*/
        END IF;
    END IF;
END
AFTER EACH ROW;

END;
4

1 回答 1

1

使用 after 语句而不是 BEFORE EACH ROW。

于 2017-12-12T08:47:57.997 回答