我正在尝试在数组中保存一组ID:
declare
cities_ids array_of_numbers;
begin
select id into cities_ids from objects where id = 1115464;
FOR i IN 1..cities_ids.COUNT LOOP
DBMS_OUTPUT.PUT_LINE(cities_ids(i));
END LOOP;
end;
执行后,我收到了下一个错误:
ORA-00932: inconsistent datatypes. Expected UDT, got NUMBER.
请解释我做错了什么......
答案 0 :(得分:26)
非常简单:BULK COLLECT
缺失。
declare
cities_ids arrayofnumbers;
begin
select object_id BULK COLLECT into cities_ids from nc_objects where object_id = 1000;
FOR i IN 1..cities_ids.COUNT LOOP
DBMS_OUTPUT.PUT_LINE(cities_ids(i));
END LOOP;
end;