如何在Oracle PL / SQL中SELECT IN数组数组?

前端之家收集整理的这篇文章主要介绍了如何在Oracle PL / SQL中SELECT IN数组数组?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试在数组中保存一组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缺少.
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;
原文链接:https://www.f2er.com/oracle/204899.html

猜你在找的Oracle相关文章