【问题标题】:How to SELECT INTO array of Numbers in Oracle PL/SQL?如何在 Oracle PL/SQL 中选择 INTO 数组?
【发布时间】:2014-08-20 17:39:30
【问题描述】:

我正在尝试将一组 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.

请解释我做错了什么...

【问题讨论】:

  • here也许这对你有帮助。

标签: sql oracle plsql


【解决方案1】:

很简单:BULK COLLECT 不见了。

declare
 cities_ids array_of_numbers;
begin
select id BULK COLLECT 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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-21
    • 1970-01-01
    • 1970-01-01
    • 2017-05-29
    • 1970-01-01
    • 2017-03-18
    相关资源
    最近更新 更多