这是代码
declare
a integer;
begin
select to_char(to_date('1/1/2017 ','mm/dd/yyyy') + level -1) into a from dual
connect by level <=365;
for a in 1..3 loop
dbms_output.put_line(a);
end loop;
end;
发生错误的是精确获取请求更多行数 请帮忙
答案 0 :(得分:0)
您正尝试在缩放器变量中获取多个值。
试试这个:
begin
for i in (select to_char(to_date('1/1/2017 ','mm/dd/yyyy') + level -1) col
from dual
connect by level <=365) loop
for j in 1..3 loop
dbms_output.put_line(i.col);
end loop;
end loop;
end;
/
答案 1 :(得分:0)
首先,请注意您宣布&#34; a&#34;变量为整数但随后为其分配varchar2。
2,我正在测试你的代码,似乎level <= 365
存在问题。
我将其更改为level = 365
,它似乎返回了预期的结果。
declare
a integer;
begin
select to_char(to_date('1/1/2017 ','mm/dd/yyyy') + level -1) into a from dual
-- connect by level <= 365;
connect by level = 365;
for a in 1..3 loop
dbms_output.put_line(a);
end loop;
end;