declare
dwmc vw_dwdmdyb.dwmc%type;
cursor dw is select b.dwmc from vw_dwdmdyb b;
begin
open dw;
loop
fetch dw into dwmc;
exit when dw%notfound;
select count(k.tbdw) as 份数, sum(k.zbde) as 金额
from (select t.* from bo_ht_zytk t where t.qyzt = '有限公司') k
where k.lxqxks > '2004-06-06'
and k.lxqxjs < '2008-10-10'
and k.sfzxwb = '否'
and rownum<9999999999999999;
end loop;
end;
怎么老是提示,select语句中没有into语句啊。
dwmc vw_dwdmdyb.dwmc%type;
cursor dw is select b.dwmc from vw_dwdmdyb b;
begin
open dw;
loop
fetch dw into dwmc;
exit when dw%notfound;
select count(k.tbdw) as 份数, sum(k.zbde) as 金额
from (select t.* from bo_ht_zytk t where t.qyzt = '有限公司') k
where k.lxqxks > '2004-06-06'
and k.lxqxjs < '2008-10-10'
and k.sfzxwb = '否'
and rownum<9999999999999999;
end loop;
end;
怎么老是提示,select语句中没有into语句啊。
select 列 into 变量 from 表where 条件
这样的格式
from (select t.* from bo_ht_zytk t where t.qyzt = '有限公司') k
where k.lxqxks > '2004-06-06'
and k.lxqxjs < '2008-10-10'
and k.sfzxwb = '否'
and rownum <9999999999999999;
这段sql文和游标是没有的关系的,count(k.tbdw) as 份数, sum(k.zbde) as 金额需要into到两个变量中去
from (select t.* from bo_ht_zytk t where t.qyzt = '有限公司') k
where k.lxqxks > '2004-06-06'
and k.lxqxjs < '2008-10-10'
and k.sfzxwb = '否'
and rownum <9999999999999999;
這個在循環里 什么作用都沒起到啊 ~ 放在循環里 卻和循環沒有關系~
from (select t.* from bo_ht_zytk t where t.qyzt = '有限公司') k
where k.lxqxks > '2004-06-06'
and k.lxqxjs < '2008-10-10'
and k.sfzxwb = '否'
and rownum <9999999999999999;
count(k.tbdw) as 份数, sum(k.zbde) as 金额需要into到两个变量中去,可能要分开来写
from (select t.* from bo_ht_zytk t where t.qyzt = '有限公司') k
where k.lxqxks > '2004-06-06'
and k.lxqxjs < '2008-10-10'
and k.sfzxwb = '否'
and rownum <9999999999999999;
loop
fetch c_mid_cgbz into I_CGBZ ;
DBMS_OUTPUT.put_line('cgbz:'||I_CGBZ) ;
exit when c_mid_cgbz%notfound ;
end loop ;
close c_mid_cgbz ;
end PRO_T_YYCF_MID_UPDATE;
请高手帮我看一下。 为什么我打印DBMS_OUTPUT 这句有问题
from (select t.* from bo_ht_zytk t where t.qyzt = '有限公司') k
这个select语句没有into啊
这一行缺少into,插入变量
还要注意查询语句返回的行数
DBMS_OUTPUT.put_line('cgbz:'||I_CGBZ) ;要改为
DBMS_OUTPUT.put_line('cgbz:'||I_CGBZ.cgbz ) ;