求助!游标无法实现外循环!

jokeboy23 2014-04-20 12:55:30
想实现游标外部的循环,总共循环12次,每次i值加1,然后i值传递到游标中在进行,但每次在执行一次循环后直接跳出,不明原因,求解答!
int i=1

decimal bi,bj,bk,bk1
string zth,jv

for i=1 to 12 //无法实现循环!!!!!!!一次循环后直接跳出
boolean r_flag=true
//i=1
sle_1.text=string(i)
declare i cursor for select distinct 科目代码 from 资产负债表 where 年份='2013' and 月份=:i;
open i;
do while r_flag=true

fetch i into :zth;
if sqlca.sqlcode=100 then
r_flag=false
end if

if sqlca.sqlcode =-1 then
messagebox("提示","读取数据失败!请重新配置ODBC!",exclamation!)
return
end if
if i<10 then
jv=Trim('20130'+string(i))
else
jv=Trim('2010'+string(i))
end if

//i=3
//jv=Trim('20130'+string(i))
if sqlca.sqlcode=0 then
if zth<>'NULL' then
select EDEBIT into :bi from balance where subid=:zth and moneyid='0' and yearmon=:jv using ltrasy;////////,ECREDIT EDEBIT
select ECREDIT into :bj from balance where subid=:zth and moneyid='0' and yearmon=:jv using ltrasy;
bj=round(bj,2)
bi=round(bi,2)
if bj>=0 then
bk=bj;
else
bk=bi;
end if
if string(bk)<>'NULL' then
ddlb_1.additem(string(bk))
sle_1.text=string(bk)
end if
if i=1 then
select 年初数 into :bk1 from 资产负债表 where 年份='2013' and 月份=:i and 科目代码=:zth using ltrasy;
bk1=round(bk1,2)
sle_2.text=string(bk1)
elseif i>1 then
select 期末数 into :bk1 from 资产负债表 where 年份='2013' and 月份=:i and 科目代码=:zth using ltrasy;
bk1=round(bk1,2)
sle_2.text=string(bk1)
end if
if abs(bk)<>abs(bk1) then
messagebox("","wrong")
update 资产负债表 set 验证='1' where 科目代码=:zth and 月份=:i using ltrag;
commit using ltrag;
bk1=0
bi=0
bj=0
else
bk1=0
bi=0
bj=0
end if
end if
end if
loop

close i;

next


dw_1.retrieve('1')
...全文
310 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

743

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 脚本语言
社区管理员
  • 脚本语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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