-- создали типы
drop type t_number;
create or replace type t_number as object(id number);
drop type t_arary_number;
create or replace type t_array_number is table of t_number;
/
-- хранимка
-- парсит массив members_id_in в объектную таблицу
-- после этого вычитываются данные из all_objects по связке array.id = object_id
create or replace procedure test_sp
is
id number;
i number := 1;
j number;
t_tab t_array_number := t_array_number();
members_id_in clob := '|2|3|4|5|6|7|8|9|10|';
clob_len number := dbms_lob.getlength(members_id_in);
begin
dbms_output.put_line('started...');
-- creating object table containts members id
while (i < clob_len) loop
j := dbms_lob.instr(members_id_in, '|', i + 1);
id := dbms_lob.substr(members_id_in, j - i - 1, i + 1);
i := j;
t_tab.extend();
t_tab(t_tab.last) := t_number(id);
end loop;
-- testing
select count(1) into i
from all_objects
where object_id in (
select id from TABLE(CAST(t_tab as t_array_number))
);
dbms_output.put_line('items count=' || i);
select count(1) into i from TABLE(CAST(t_tab as t_array_number));
dbms_output.put_line('items count=' || i);
exception
when others then
dbms_output.put_line( substr(sqlerrm, 1, 200) );
end;
/
почему для первого запроса возвращается всегда 0? ответ искал в доках - не нашел.
если соединяем с all_objects, то возвращается всегда 0, но записи с такими object_id в all_objects есть
(второй запрос лишь тест, чтобы убедиться, что в табличку попали все распарсенные данные).
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for Linux: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production