sql server 存储过程
2015-10-13 11:42
483 查看
USE [NyghSql] GO /****** Object: StoredProcedure [dbo].[delete_date] Script Date: 10/13/2015 17:30:06 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER procedure [dbo].[delete_date] ( @applycode nvarchar(100) ) as --声明变量 定义变量用逗号隔开 declare @applycode_var nvarchar(100), @instanceid_var nvarchar(100), @t_ywsloid_var nvarchar(100), @areaPart_oid nvarchar(100), @areaPartoid nvarchar(100) begin --查出 工作流实例 select @instanceid_var=Instanceid from t_ywsl where applycode=@applycode --删除 工作流实例对应的任务表(待办和已办) delete from AssignTask where AssignTasK.Instanceid=@instanceid_var --查询业务受理oid select @t_ywsloid_var=t_ywsloid from t_ywsl where applycode=@applycode --循环删除对应的坐标范围 --sql server --定义游标 declare my_cursor cursor --读取数据放到游标中 for(select AreaPartoid from AreaPart where T_YWSLOID=@t_ywsloid_var) --打开游标 open my_cursor --读取集合中的第一行数据 fetch next from my_cursor into @areaPart_oid --全局变量,0表示fetch语句成功;-1表示语句失败或此行不在结果集中;-2被提取的行不存在 while @@FETCH_STATUS=0 begin delete from AreaPoints where AreaPartOID=@areaPart_oid --读取下一行 fetch next from my_cursor into @areaPart_oid end close my_cursor deallocate my_cursor --删除对应的地块列表 delete from AreaPart where T_YWSLOID=@t_ywsloid_var --删除对应的附件管理 delete from FileManage where T_YWSL_FK=@t_ywsloid_var --审批意见 delete from SPYJ where T_YWSL_FK=@t_ywsloid_var --流程意见 --工作流实例记录本 delete from FlowInstance where Instanceid=@instanceid_var; --活动转移条件集 declare t_cursor cursor for select TaskTicketoid from TaskTicket where Instanceid=@instanceid_var open t_cursor fetch next from t_cursor into @areaPartoid while @@FETCH_STATUS=0 begin delete from TransConditionEx where TaskTicket_FK=@areaPartoid fetch next from t_cursor into @areaPartoid end close t_cursor deallocate t_cursor --任务表 delete from TaskTicket where Instanceid=@instanceid_var --业务受理表 delete from t_ywsl where applycode=@applycode end
相关文章推荐
- 利用ORACLE 11g 新特性创建物理备库
- Mac 将mysql路径加入环境变量
- oracle中的rownum、order by与分页
- 【解决】Mysql字符集问题
- MySql查询结果按照指定顺序排序
- Oracle中group by用法
- Mysql用户权限管理
- 架构之路(五):忘记数据库
- 使用JDBC的addBatch()方法提高数据库插入更新效率
- mysql之InnoDB内存管理
- vnc配合oracle sqldeveloper 本地基本连接操作 centos
- 数据库主键生成策略 方法集合
- mysqldump: Couldn't execute 'SET OPTION SQL_QUOTE_SHOW_CREATE=1'
- 使用Python操作Memcached
- 有关数据库SQL递归查询在不同数据库中的实现方法
- ORACLE 12C 冷备份方式的数据迁移(rename方式)
- 关于 SQL Server 登录问题(错误 233和18456)的解决方法
- 查询数据库当前连接数(session),进程数等操作
- SqlServer 数据库 分离复制备份然后附加回数据库 sql代码
- oracle 服务基本操作,启动,停止 故障处理