我正在尝试在数组中保存一组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.
请说明我做错了什么
很简单:BULK COLLECT缺少.
原文链接:https://www.f2er.com/oracle/204899.htmldeclare 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;