如何在 Oracle PL/SQL 中选择 INTO 数字数组?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24488620/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 02:08:48 来源:igfitidea点击:
How to SELECT INTO array of Numbers in Oracle PL/SQL?
提问by Boris Mitioglov
I'm trying to save set of ids in array:
我正在尝试将一组 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;
After execution, I got next error:
执行后,我得到了下一个错误:
ORA-00932: inconsistent datatypes. Expected UDT, got NUMBER.
Please explain what I did wrong...
请解释我做错了什么...
回答by Erich Kitzmueller
Very simple: BULK COLLECT
is missing.
很简单: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;