游标可以嵌套循环吗?

margg 2004-04-29 05:54:25
boolean lb_continue6,lb_6
declare cu_pcn6 cursor for
select id,p_cn from user_m where s_cn = :ls_pcn5;
open cu_pcn6;
Do while lb_continue6
Fetch cu_pcn6 into :li_userid6,:ls_pcn6;
if sqlca.sqlcode = 0 then
declare cu_assess6 cursor for
select assess from orderbill
where userid = :li_userid6
and year(makedate) = :li_year
and month(makedate) = :li_month ;
open cu_assess6;
Do while lb_6
Fetch cu_assess6 into :ld_assess6;
if sqlca.sqlcode = 0 then ld_total6 = ld_total6 + ld_assess6
else
lb_6 = false
end if
Loop
close cu_assess6;
else
lb_continue6 = false
end if
Loop
close cu_pcn6;
...全文
95 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zysys 2004-04-30
  • 打赏
  • 举报
回复
可以.
例子:
DECLARE lcs_bat CURSOR FOR
select qut,ide_bat,dat_eff
from pro_bat_ide
where dep=:gl_dep and uqi_pro=:ll_uqi and qut>0;
OPEN lcs_bat;
FETCH lcs_bat INTO :ldc_qut,:ls_batide,:ldt_effdat;
DO WHILE sqlca.sqlcode=0
if MessageBox("发现该商品有“"+string(ll_CouRow)+"”个批号:","批号"+ls_batide+"数量为:"+string(ldc_qut)+"有效期为:"+string(ldt_EffDat,"yyyy.mm.dd")+"~r~n~r~n是否选择该批号的商品?",None!,YesNo!)=1 then
Exit
end if
FETCH lcs_bat INTO :ldc_qut,:ls_batide,:ldt_effdat;
LOOP
CLOSE lcs_bat;
foxphoenix 2004-04-30
  • 打赏
  • 举报
回复
可以,慢的要命
10975037 2004-04-30
  • 打赏
  • 举报
回复
是可以的!
hzhxxx 2004-04-29
  • 打赏
  • 举报
回复

可以,但是不能使用相同的数据库事务

1,108

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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