alter proc test_proc2
@pro_catalog_money_class_guid varchar(50), --定义输入参数:经费类别、 项目编号
@pro_guid varchar(50)
-- @ysyong decimal(15,4) output
--定义输出参数:已使用经费
as
declare @objuid varchar(50),@pro_shqing_money_value varchar(50) , @ifareid varchar(50)
declare test_proc_row_number cursor for --定义游标 1 ( test_proc_row_number )
select s.objuid,s.pro_shqing_money_value from t_pro_shqing_money s
inner join t_pro_catalog_money_class c on c.objuid=s.pro_catalog_money_class_guid
where s.pro_catalog_money_class_guid= @pro_catalog_money_class_guid and s.pro_guid=@pro_guid
and sfzf!=3 and che_xiao_ly is nullOPEN test_proc_row_number --打开游标
fetch next from test_proc_row_number Into @objuid,@pro_shqing_money_value ----读取游标中的第一条数据,并分别存储在变量中
--判断是否从游标中取得数据
while (@@FETCH_STATUS=0)
begin
fetch next from test_proc_row_number into @objuid,@pro_shqing_money_value declare test_proc_row_number_co_feiy cursor for --定义游标 2
select co_feiys.ifareid from co_feiys
inner join co_feiy on co_feiy.ifareid=co_feiys.ifareid
where co_feiy.a02=@objuid
open test_proc_row_number_co_feiy --打开游标
fetch next from test_proc_row_number_co_feiy into @ifareid
while (@@FETCH_STATUS=0)
begin
fetch next from test_proc_row_number_co_feiy into @ifareid
print 'ifareid=='+@ifareid
end
close test_proc_row_number_co_feiy
deallocate test_proc_row_number_co_feiy
end
--关闭游标
close test_proc_row_number
--删除游标
deallocate test_proc_row_number不知道 为啥,里面 print 'ifareid=='+@ifareid 输出 的是外层循环的 第二条数据 ,谢谢帮我看看
@pro_catalog_money_class_guid varchar(50), --定义输入参数:经费类别、 项目编号
@pro_guid varchar(50)
-- @ysyong decimal(15,4) output
--定义输出参数:已使用经费
as
declare @objuid varchar(50),@pro_shqing_money_value varchar(50) , @ifareid varchar(50)
declare test_proc_row_number cursor for --定义游标 1 ( test_proc_row_number )
select s.objuid,s.pro_shqing_money_value from t_pro_shqing_money s
inner join t_pro_catalog_money_class c on c.objuid=s.pro_catalog_money_class_guid
where s.pro_catalog_money_class_guid= @pro_catalog_money_class_guid and s.pro_guid=@pro_guid
and sfzf!=3 and che_xiao_ly is nullOPEN test_proc_row_number --打开游标
fetch next from test_proc_row_number Into @objuid,@pro_shqing_money_value ----读取游标中的第一条数据,并分别存储在变量中
--判断是否从游标中取得数据
while (@@FETCH_STATUS=0)
begin
fetch next from test_proc_row_number into @objuid,@pro_shqing_money_value declare test_proc_row_number_co_feiy cursor for --定义游标 2
select co_feiys.ifareid from co_feiys
inner join co_feiy on co_feiy.ifareid=co_feiys.ifareid
where co_feiy.a02=@objuid
open test_proc_row_number_co_feiy --打开游标
fetch next from test_proc_row_number_co_feiy into @ifareid
while (@@FETCH_STATUS=0)
begin
fetch next from test_proc_row_number_co_feiy into @ifareid
print 'ifareid=='+@ifareid
end
close test_proc_row_number_co_feiy
deallocate test_proc_row_number_co_feiy
end
--关闭游标
close test_proc_row_number
--删除游标
deallocate test_proc_row_number不知道 为啥,里面 print 'ifareid=='+@ifareid 输出 的是外层循环的 第二条数据 ,谢谢帮我看看
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货