一个关于存储过程和游标的问题。。求助

pixiaozheng 2010-08-10 08:55:36

create or replace procedure proc_getcursor_value(Fyear IN CHAR,
Fmonth IN CHAR)
is

v_orgid ia_ia_bill_line.org_id%TYPE;
v_stockorgid ia_ia_bill_head.stock_org_id%TYPE;
v_styleid ia_ia_bill_line.style_id%TYPE;
v_ornacode ia_ia_bill_line.orna_code%TYPE;
v_num ia_ia_bill_line.num%TYPE;
i number:=1;
cursor term_type is
SELECT h.org_id, h.stock_org_id, l.style_id, l.orna_code, l.num
FROM ia_ia_bill_head h, ia_ia_bill_line l
where h.id=l.head_id
and h.fiscal_year=Fyear
and h.fiscal_month=Fmonth
and h.transceiver_flag<>1;
begin
Open term_type;
loop
fetch term_type into v_orgid,v_stockorgid,v_styleid,v_ornacode,v_num;
i :=i+1;
if term_type%notfound
then
dbms_output.put_line('个数'||i);
exit;
end if;
end loop;
close term_type;
end proc_getcursor_value;




上面那个游标的select语句大概有9W多条语句,为什么打印的时候,i只为2?
...全文
35 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Phoenix_99 2010-08-10
  • 打赏
  • 举报
回复
首先你把你的游标加上过程的输入值,放到sql里执行,看能查出多少来
游标最后一般定位到最后一行符合条件的记录上,
按你打印的数据为2,应该是没有查出数据来。
i number:=1;
一般赋值为0
pixiaozheng 2010-08-10
  • 打赏
  • 举报
回复
这个没问题的。。
我没有打印个数了。。我建了个临时表,循环的时候向表里插数据,存储过程执行完毕后,临时表里的数据时9W多条的
hidanger0 2010-08-10
  • 打赏
  • 举报
回复
我感觉你什么都没有查询出来。
SELECT h.org_id, h.stock_org_id, l.style_id, l.orna_code, l.num
FROM ia_ia_bill_head h, ia_ia_bill_line l
where h.id=l.head_id
and h.fiscal_year=Fyear
and h.fiscal_month=Fmonth
and h.transceiver_flag<>1;
关注一下Fyear、Fmonth条件是否满足。
建议你把sql语句打印出来试一下。

3,491

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 高级技术相关讨论专区
社区管理员
  • 高级技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧