问题描述
- PLSQL循环嵌套查询,查询结果一直不打印输出
-
declare
-- Local variables here
i integer := 1;
currentdate timestamp;
ninsdate timestamp;
nseqid number;
ndate varchar2(10);
nspid varchar2(10);
po INTEGER;
begin
ndate := '201506';
nspid := '33474';
po:=0;
select sysdate + 1 / (24 * 60) into currentdate from dual;
ninsdate := currentdate + 1 / 1440;
for c in (select *
from userorder t
where t.producttype = '1'
and substr(t.ordertime, 1, 6) < '201506'
and t.spid = '33474') loop
if (i = 60) then
i := 1;
ninsdate := ninsdate + 1 / (24 * 60);
end if;
--下面代码没执行输出,不确定为什么
select count(*)
into po
from sgip_report pt
where pt.usernumber = c.usernumber
and pt.insdate > TO_DATE('2015-06-07', 'yyyy-mm-dd')
and pt.state = '0';
dbms_output.put_line(po);--没有打印结果,我后续判断用
if po=0 then
--插入操作
end if;
end loop;
end;后台没有打印信息,一直在执行,也没有结束,不是死循环呀,大神帮忙看看
解决方案
最上面加一句 set serveroutput on试试
时间: 2024-10-19 06:28:30