我试图让它运行但无法弄清楚为什么它不运行。我正在尝试创建一个 pl/sql 块,它将读取 2 个代码并确保它们在插入之前存在:
declare
v_old_atty_id in atty_rules.attorney_id%type;
v_new_atty_id in atty_rules.attorney_id%type;
type rule_array is varray(10000) of number;
v_rule rule_array;
begin
select distinct rule_id
bulk collect into v_rule
from atty_rules
where attorney_id = v_old_atty_id
and date_activated <= sysdate
and sysdate < nvl(date_deactivated, sysdate+1);
if exists (select attorney_id
from ORG_ATTYS
where attorney_id = v_new_atty_id)
for indx in 1..v_rule.count
loop
insert into atty_rules (attorney_id,rule_id)
values (v_new_atty_id, v_rule(indx));
end loop
else
dbms_output.put_line('Doesnt exist')
end if;
end;
任何方向都会有很大帮助,谢谢。