我无法设置"全球"变量表在所有coumpound触发器部分都有效。
简化示例(在我的实例中,我会收集一些ID然后在AFTER部分执行操作)
create or replace
TYPE couple_ids is table of number;
CREATE OR REPLACE TRIGGER trig_on_voice_tags_upd_del
FOR UPDATE OR DELETE ON voice_tags
COMPOUND TRIGGER
table_ids couple_ids;
BEFORE STATEMENT IS
BEGIN
table_ids:= couple_ids();
table_ids.extend;
dbms_output.put_line('BEFORE STATEMENT size:' || table_ids.count );
NULL;
END BEFORE STATEMENT;
BEFORE EACH ROW IS
BEGIN
dbms_output.put_line('BEFORE EACH ROW IS size:' || table_ids.count );
NULL;
END BEFORE EACH ROW;
AFTER EACH ROW IS
BEGIN
dbms_output.put_line('AFTER EACH ROW size:' || table_ids.count );
NULL;
END AFTER EACH ROW;
AFTER STATEMENT IS
BEGIN
dbms_output.put_line('AFTER STATEMENT size:' || table_ids.count );
NULL;
END AFTER STATEMENT;
END trig_on_voice_tags_upd_del;
不幸的是,我得到 ORA-06531:在" dbms_output.put_line的行上引用未初始化的集合('在每个行的大小之前:' || table_ids。计数);"
为什么 table_ids 在所有部分中都不可见(已初始化)?