declare
l_vc_arr2 apex_application_global.vc_arr2;
l_id number;
begin
l_vc_arr2 := apex_util.string_to_table(:P422_ORGANIZACIONES);
delete
from items_distribucion_config_org
where id_itdico = to_number(:P422_ID_ITDICO)
and ':' || :P422_ORGANIZACIONES || ':' not like '%:' || idorganizacion || ':%';
for i in 1..l_vc_arr2.count loop
begin
select id_idcorg
into l_id
from items_distribucion_config_org
where id_itdico = to_number(:P422_ID_ITDICO)
and idorganizacion = to_number(l_vc_arr2(i));
exception
when no_data_found then
insert
into items_distribucion_config_org (
id_itdico
, idorganizacion
, ind_activo
) values (
:P422_ID_ITDICO
, l_vc_arr2(i)
, 1
);
end;
end loop;
end;