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的更多相关文章

  1. sql中的begin catch 。。。end catch 的用法

    begin catch ...end  catch 是用来处理异常的 begintry--SQLendtry begincatch--sql (处理出错动作)endcatch 我们将可能会出错的sql ...

  2. SQL 中的Begin...End语句

    Begin...End通常用来表示一个语句块,其内部的代码可以包含一组T-SQL语句,可以理解为高级语言中的{},这样在使用while循环时才知道判断什么时候结束.

  3. 在SQL中使用CLR提供基本函数对二进制数据进行解析与构造

      二进制数据包的解析一般是借助C#等语言,在通讯程序中解析后形成字段,再统一单笔或者批量(表类型参数)提交至数据库,在通讯程序中,存在BINARY到struct再到table的转换. 现借助CLR提 ...

  4. SQL中的循环、for循环、游标

    我们使用SQL语句处理数据时,可能会碰到一些需要循环遍历某个表并对其进行相应的操作(添加.修改.删除),这时我们就需要用到咱们在编程中常常用的for或foreach,但是在SQL中写循环往往显得那么吃 ...

  5. Qt调用Server SQL中的存储过程

    Server SQL中的存储过程如下: CREATE procedure PINSERTPC @pcnum int, @pcname varchar(50), @pctype int, @ipaddr ...

  6. SQL中查看数据库各表的大小

    SQL中查看数据库各表的大小 编写人:CC阿爸 2014-6-17 在日常SQL数据库的操作中,如何快速的查询数据库中各表中数据的大小. 以下有两种方法供参考: 第一种: create table # ...

  7. SQL中删除某数据库所有trigger及sp

    SQL中删除某数据库所有trigger及sp   编写人:CC阿爸 2014-6-14 在日常SQL数据库的操作中,如何快速的删除所有trigger及sp呢 以下有三种方式可快速处理. --第一种 - ...

  8. SQL中补0

     SQL中补0 编写人:CC阿爸 2014-3-14 第一种方法: right('00000'+cast(@count as varchar),5) 其中'00000'的个数为right函数的最后参数 ...

  9. 在SQL中取出字符串中数字部分或在SQL中取出字符部分

    在SQL中取出字符串中数字部分或在SQL中取出字符部分 编写人:CC阿爸 2013-10-18 近来在开发一个项目时,一包含数字的字符串,需要取出中间的数字部分进行排序.经过baidu搜索.并结合自己 ...

随机推荐

  1. AWS:2.根设备类型、EC2生命周期状态、User Data

    主要内容 1.根设备类型 linux: /dev/sda1 windows: 系统盘 2.实例生命周期 生命周期状态:停止.终止.重启 3.用户数据(UserData) 实例在初始化,运行之前给定的用 ...

  2. Moving Computation is Cheaper than Moving Data

    https://hadoop.apache.org/docs/r1.2.1/hdfs_design.html Introduction The Hadoop Distributed File Syst ...

  3. Javascript模块化编程-规范[2]

    实现Javascript模块化,固然很重要,但是怎样才能实现国际上都能认可的模块化呢?模块化编程规范随应运而生. 目前Javascript模块化规范主要有两种:CommonJS和AMD. Common ...

  4. 【题解】 P1092虫食算

    [题解]P1092 虫食算 老题了,很经典. 用到了一些搜索套路. 可行性剪枝,劣者靠后,随机化,\(etc......\) 搜索设参也很有技巧,设一个\(adjustment\)参数可以很方便地在两 ...

  5. python manage.py shell 的增删改查

    python manage.py shell 的增删改查 guoguo-MacBook-Pro:myblog guoguo$ python manage.py shell Python 3.5.1 ( ...

  6. oracle 数据库常用数据表操作

    在oracle中创建sequence CREATE SEQUENCE sequence名称 MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCRE ...

  7. Android环境下通过C框架层控制WIFI【转】

    本文转载自:https://blog.csdn.net/edw200/article/details/52192631 本人是从事Linux嵌入式开发的,安卓wifi控制在安卓JAVA层已经做得非常成 ...

  8. Android 4.0 的 GridLayout

    设计素材代码: 1<?xml version="1.0" encoding="utf-8"?> 2<GridLayout//#http://w ...

  9. 分享知识-快乐自己:初识 Hibernate 概念片(一)

    1):什么是 Hibernate? Hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一个全自动的orm框架,hibe ...

  10. Linux_学习_01_ 压缩文件夹

    二.参考资料 1.Linux下压缩某个文件夹命令