SSIS Package的Executable存在层次结构,例如Package位于层次结构的最顶层,Root Level;Container是其中包含的Executable(Task 或 Container)的Parent Level。如果Event 发生在Child Level,首先会被Child Level的Event Handler捕获,并处理;如果Child Level没有相应的Event handler,那么该Event会向上传递给其Parent Executable,由其Parent Executable的Event Handler来处理。Event依次向上传递的过程就是Propagate。

MSDN对Propagate的官方定义是:

Propagate is a system variable for event handlers, indicates whether the event is propagated to a higher level event handler.

Note:The value of the Propagate variable is disregarded during the validation of the package. If you set Propagate to False in a child package, this does not prevent an event from propagating up to the parent package.

1,OnError 事件具有Propagate特性

当Child Event Handler 处理OnError事件之后,OnError事件仍然会向上传递,直到最顶层的Package。

例如,在Package 和 Executable级别分别创建了OnError Event Handler,如下图:

下图是Executable级别的OnError Event Handler,其成功执行一个Task。

但是,OnError事件继续向上传递,被Package级别的OnError Event Handler捕获并处理之后,Package仍然报错:Package execution completed with error.

Event 的 Propagate 过程类似“冒泡”,从触发的Task开始,向上传递到最顶层的Executable,最顶层的Executable是 Package 本身。如果在 package 级别定义了一个Event handler,那么每当Event 发生在 package 中,都会触发该 Event Handler。如果Package使用Execute Package Task来执行子package,那么也会发生相同的过程,子package的Event会propagate到父package中。

2,关闭Event的Propagate

如果希望关闭Event的propagate过程,可以在子 Taske 的Event Handler中,将系统变量Propagate设置为false,这样,Event将不会向上传递,而只触发当前Task的Event Handler。系统变量Propagate的默认值是True。

step1,在Variables 窗体中,点击Grid Options,打开Variable Grid Options 窗体,勾选Show system variables

step2,在 Variables 窗体中,找到 Propagate 系统变量(Scope是OnError),将Value设置为False

3,当Event的Propagate 关闭之后,Event只会被触发的Task的Event Handler捕获并处理,而不会向上传递。

再次执行Package,由于OnError 事件是被child Execute SQL Task触发的,其Event handler捕获并处理该OnError事件

而Package级别的Event Handler并没有捕获到OnError事件,package的执行结果是Success。

Appendix:

引用《Integration Services (SSIS) Event Handlers》:

At run time, executables (packages and Foreach Loop, For Loop, Sequence, and task host containers) raise events. For example, an OnError event is raised when an error occurs. If an event has no event handler, the event is raised to the next container up the container hierarchy in a package. If this container has an event handler, the event handler runs in response to the event. If not, the event is raised to the next container up the container hierarchy.

The following diagram shows a simple package that has a For Loop container that contains one Execute SQL task.

Only the package has an event handler, for its OnError event. If an error occurs when the Execute SQL task runs, the OnError event handler for the package runs. The following diagram shows the sequence of calls that causes the OnError event handler for the package to execute.

Event handlers are members of an event handler collection, and all containers include this collection. If you create the package using SSIS Designer, you can see the members of the event handler collections in the Event Handlers folders on the Package Explorer tab of SSIS Designer.

参考doc:

Integration Services (SSIS) Event Handlers

System Variables

最新文章

  1. javascript - 封装原生js实现ajax
  2. Atitit 项目管理(5)----------后勤管理与工具链支持管理
  3. SignalR与ActiveMQ结合构建实时通信
  4. Java Hour2
  5. Oracle连乘聚合函数 MUL
  6. asp.net 创建文字特效
  7. Android中Bitmap, Drawable, Byte,ID之间的转化
  8. Android 多线程断点下载
  9. QTP常见问题解决方法(一)
  10. 基于TCP的NAT子网穿透实验
  11. 4G
  12. [转]sleep和wait的区别
  13. history.js 一个无刷新就可改变浏览器栏地址的插件(不依赖jquery)
  14. webrtc教程
  15. openGL光源概念
  16. Sitecore® 8.2 Professional Developer考试心得
  17. spring boot 集成disconf
  18. 一个python代码练习
  19. 【代码笔记】iOS-NSTimer
  20. Android 设备管理API概览(Device Administration API)

热门文章

  1. dedecms循环列表样式
  2. HDU4787 GRE Words Revenge(AC自动机 分块 合并)
  3. React Native MAC上环境搭建笔记
  4. (转) 注意啦,笔记本是无线的,虚拟机上网方式莫用NAT,好难整。
  5. 如何删除 eclipse debugger 下不用的Java Application
  6. c# 局域网文件传输实例
  7. ST
  8. (转)Vsdocman7.2 注册版
  9. oracle--导出、导入blob类型的字段
  10. jQuery代码节选(css)