SQL递归处理数据
来源:互联网 发布:一元抢购软件 编辑:程序博客网 时间:2024/05/22 06:05
/*
根据前置任务的时间,修改后续任务的时间
@ParentCyclePlanId:前置任务编号
*/
ALTER Proc ChangeCyclePlanDate
@ParentCyclePlanId int
As
Declare @CyclePlanId Int, @CyclePlanEndTime Char(10), @State Int, @Temp Char(10), @Other Char(10)
--声明游标
Declare CyclePlan_Cursor Cursor Local
For
Select CyclePlanId, CyclePlanStartTime, CyclePlanEndTime From CyclePlan Where PrepositiveCyclePlan = @ParentCyclePlanId
For Update Of CyclePlanStartTime, CyclePlanEndTime
Open CyclePlan_Cursor
--如果没有后续任务则释放游标,并立即返回
If @@Cursor_Rows = 0
Begin
Close CyclePlan_Cursor
Deallocate CyclePlan_Cursor
Return
End
--递归
Select @CyclePlanEndTime = CyclePlanEndTime From CyclePlan Where CyclePlanId = @ParentCyclePlanId
Fetch CyclePlan_Cursor
Into @CyclePlanId, @Temp, @Other
Select @State = @@Fetch_Status
While @State = 0
Begin
Update CyclePlan Set
CyclePlanStartTime = replace(Convert(Char(10), DateAdd(day, 1, @CyclePlanEndTime), 111), '/', '-'),
CyclePlanEndTime = replace(Convert(Char(10), DateAdd(day, DateDiff(day, @Temp, CyclePlanEndTime) + 1, @CyclePlanEndTime), 111), '/', '-')
Where Current Of CyclePlan_Cursor
Exec ChangeCyclePlanDate @ParentCyclePlanId = @CyclePlanId
Fetch CyclePlan_Cursor
Into @CyclePlanId, @Temp
Select @State = @@Fetch_Status
End
Return
- SQL递归处理数据
- SQL递归查询数据
- SQL递归查询数据
- SQL处理重复数据
- SQL 处理数据 curd
- SQL SERVER与oracle中的递归处理
- php递归处理无限极数据
- 在SQL中递归查询数据
- sql server 2000 递归显示数据
- SQL使用递归实现数据的累加
- SQL树形数据的处理
- 动态SQL 处理BLOB数据
- sql 2005 循环处理数据
- 递归处理
- js递归处理数据,并且渲染页面(表格)
- sql递归
- SQL递归
- 递归SQL
- 系统设计
- Linux网卡驱动分析
- javascript返回可见网页区域的元素dom树
- Who Am I?
- [编程实例]Dev-C++编写动态调用dll杀进程的程序
- SQL递归处理数据
- VC++工程的文件组织
- MPLAYER播放电影很慢
- Linux之PPP初探
- C# 文件操作(上传 下载 删除 文件列表...)
- C++虚函数表解析(转)
- xml字符串中的变成了<和>,这怎么办呢
- 中文字符集简介(GB2312 GB13000(GBK) GB18030)
- C++各大有名库的介绍之C++标准库