sql中的begin....end
Begin
...
End
之间的是一个语句块,一般Begin...End用在 ( 相当于 {})
while
if等语句中
在T_SQL中,if/while后只能紧跟一条sql语句,如果有多条则应该用Begin..end包含起来
如:
if (@int > 9)
set @int = 1
else
set @int = 0
这里的if后面只把变量@int设为1,没有其它的操作,所以这里可以省去begin..end
但如果有多条,如
if(@int > 9)
begin
set @int = 1
select * from tablename
end
这里就必须用begin..end
否则
select语句就永远都会被执行一次
应用于mybatis 当有多个delete时 :
<delete id="deleteHdsqByProcessinstid">
BEGIN
delete from wfworkitem c where c.processinstid in (select b.processinstid from wfprocessinst b where b.PARENTPROCID=#processinstid#);
delete from wfactivityinst c where c.processinstid in (select b.processinstid from wfprocessinst b where b.PARENTPROCID=#processinstid#);
delete from wftransctrl e where e.processinstid in (select b.processinstid from wfprocessinst b where b.PARENTPROCID=#processinstid#);
delete from wftransition g where g.processinstid in (select b.processinstid from wfprocessinst b where b.PARENTPROCID=#processinstid#);
delete from wfwiparticipant i where i.processinstid in (select b.processinstid from wfprocessinst b where b.PARENTPROCID=#processinstid#);
delete from wfprocessinst a where a.processinstid in (select b.processinstid from wfprocessinst b where b.PARENTPROCID=#processinstid#);
delete from wfworkitem where processinstid=#processinstid#;
delete from wfactivityinst where processinstid=#processinstid#;
delete from wftransctrl where processinstid=#processinstid#;
delete from wftransition where processinstid=#processinstid#;
delete from wfwiparticipant where processinstid=#processinstid#;
delete from wfprocessinst where processinstid=#processinstid#;
END;
</delete>
sql中的begin....end的更多相关文章
- sql中的begin catch 。。。end catch 的用法
begin catch ...end catch 是用来处理异常的 begintry--SQLendtry begincatch--sql (处理出错动作)endcatch 我们将可能会出错的sql ...
- SQL 中的Begin...End语句
Begin...End通常用来表示一个语句块,其内部的代码可以包含一组T-SQL语句,可以理解为高级语言中的{},这样在使用while循环时才知道判断什么时候结束.
- 在SQL中使用CLR提供基本函数对二进制数据进行解析与构造
二进制数据包的解析一般是借助C#等语言,在通讯程序中解析后形成字段,再统一单笔或者批量(表类型参数)提交至数据库,在通讯程序中,存在BINARY到struct再到table的转换. 现借助CLR提 ...
- SQL中的循环、for循环、游标
我们使用SQL语句处理数据时,可能会碰到一些需要循环遍历某个表并对其进行相应的操作(添加.修改.删除),这时我们就需要用到咱们在编程中常常用的for或foreach,但是在SQL中写循环往往显得那么吃 ...
- Qt调用Server SQL中的存储过程
Server SQL中的存储过程如下: CREATE procedure PINSERTPC @pcnum int, @pcname varchar(50), @pctype int, @ipaddr ...
- SQL中查看数据库各表的大小
SQL中查看数据库各表的大小 编写人:CC阿爸 2014-6-17 在日常SQL数据库的操作中,如何快速的查询数据库中各表中数据的大小. 以下有两种方法供参考: 第一种: create table # ...
- SQL中删除某数据库所有trigger及sp
SQL中删除某数据库所有trigger及sp 编写人:CC阿爸 2014-6-14 在日常SQL数据库的操作中,如何快速的删除所有trigger及sp呢 以下有三种方式可快速处理. --第一种 - ...
- SQL中补0
SQL中补0 编写人:CC阿爸 2014-3-14 第一种方法: right('00000'+cast(@count as varchar),5) 其中'00000'的个数为right函数的最后参数 ...
- 在SQL中取出字符串中数字部分或在SQL中取出字符部分
在SQL中取出字符串中数字部分或在SQL中取出字符部分 编写人:CC阿爸 2013-10-18 近来在开发一个项目时,一包含数字的字符串,需要取出中间的数字部分进行排序.经过baidu搜索.并结合自己 ...
随机推荐
- 【BZOJ1786】[Ahoi2008]Pair 配对 DP
[BZOJ1786][Ahoi2008]Pair 配对 Description Input Output Sample Input 5 4 4 2 -1 -1 3 Sample Output 4 题解 ...
- android菜鸟学习笔记8----Activity(一)
Activity是android应用程序中重要的组件之一,常听到的android四大组件是Activity.Service.BroadcastReceiver和ContentProvider.它间接继 ...
- 一些重要的地址:md5在线解密破解
md5在线解密破解:https://www.cmd5.com/
- php调用短网址接口
<?php $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,"http://dwz.cn/create.php"); curl_se ...
- Tomcat学习笔记【5】--- 项目部署详解
本文主要讲在Tomcat中部署项目的几种方式:静态部署.动态部署. 一 静态部署 静态部署项目有好几种方式,比较典型的有如下4种: 1.1 方式一:将Web项目放到webApps目录下 直接将web项 ...
- Spring IOC 容器源码分析(转)
原文地址 Spring 最重要的概念是 IOC 和 AOP,本篇文章其实就是要带领大家来分析下 Spring 的 IOC 容器.既然大家平时都要用到 Spring,怎么可以不好好了解 Spring 呢 ...
- sprint-boot @ComponentScan扫描多个包
使用@ComponentScan扫描多个包时, @ComponentScan({"ka","com"}) 注意包名不能为org,不然无法启动
- Gemini.Workflow 双子工作流入门教程五:业务表单开发
简介: Gemini.Workflow 双子工作流,是一套功能强大,使用简单的工作流,简称双子流,目前配套集成在Aries框架中. 下面介绍本篇教程:业务表单开发. 业务表单开发 业务表单的开发,和在 ...
- make update-api
1) 添加系统API或者修改@hide的API后,需要执行 make update-api,然后再make 2) 修改公共api后,需要 make update-api 比较framework/ba ...
- 如何用命令行删除EasyBCD开机选择项?
用硬盘安装Ubuntu方法的windows双系统电脑上面,很多人都是用EasyBCD设置的开机启动选择.所以当我们不需要双系统的时候,或者已经删除双系统后,或者安装双系统失败的情况下,发现电脑的开机启 ...