| 发表于:2007-10-14 10:05:38 楼主 |
------定义变量-------------------------------------------------------------- declare @flowlineid int --流水线号 declare @vcontid int --容器号 ---定义流水线游标开始------------------------------------------------------ declare cursor_flowline cursor for select distinct flowlineid from zy_sort_splitorders order by flowlineid open cursor_flowline fetch next from cursor_flowline into @flowlineid while @@fetch_status = 0 begin --------------容器游标开始-------------------------------------------- declare cursor_vcontid cursor for select distinct vcontid from zy_sort_splitorders where flowlineid = @flowlineid order by vcontid open cursor_vcontid fetch next from cursor_vcontid into @vcontid while @@fetch_status = 0 begin update zy_sort_splitorders set cellcapacity = ( select sum(quantity) from zy_sort_splitorderdtls where flowlineid = @flowlineid and vcontid = @vcontid ) where flowlineid = @flowlineid and vcontid = @vcontid fetch next from cursor_vcontid into @vcontid end close cursor_vcontid deallocate cursor_vcontid --------------容器游标结束-------------------------------------------- fetch next from cursor_flowline into @flowlineid end close cursor_flowline deallocate cursor_flowline ---定义流水线游标结束------------------------------------------------------ 以上是sql server 中的存储过程,请问在db2中如何实现嵌套游标啊? |
|
|
|
|