OLE DB Command transformation component 能够引用参数,逐行调用sqlcommand,This transformation is typically used for running parameterized queries。

1,自定义属性

OLE DB Command Transformation 是一个功能十分强大的组件,但是其配置属性却是十分简单,只有三个自定义属性,如图

SqlCommand :要执行的sql 命令,使用 ? 代替一个参数,参数的值来源于上游组件的输入。

2,参数

OLE DB Command transformation Component 是一行一行进行转换的,特别是SqlCommand中可以使用参数。The parameter values are stored in external columns in the transformation input, and mapping an input column to an external column maps an input column to a parameter。

2.1 sqlcommand引用参数值

OLEDB 链接不同于Adonet链接,对参数的引用是不同的。OLEDB 链接使用?代表一个参数,?的序号从0开始,是固定的,Oledb通过序号来引用参数。

sqlcommand 用? 来引用对应序号的参数。第一个参数,序号为0,sqlcommand中第一个?引用该参数。

update dbo.tis set name=name+'_update' where code=?

type the parameterized SQL statement using a question mark (?) as the parameter marker for each parameter.

2.2 设置column mappings

在sqlcommand引用参数之后,点击refresh按钮,组件自动识别?,然后生成参数,参数名的命名规则是Param_Ordinal,需要在column mappings选项卡中设置参数的值和上游组件的输入的column之间的mapping,用于设置参数值的来源。Available input columns 是上游组件的输入列,Available destination columns是自动生成的参数列。

Click Refresh. When you click Refresh, the transformation creates a column for each parameter in the External Columns collection and sets the DBParamInfoFlags property.

示例:Param_0参数的值是由Code赋值的。

2.3 查看参数信息

在 Input and Output Properties选项卡中,选择OLE DB命令输入-》external columns,可以看到组件自动添加一个参数Param_0,其数值来源于Input Columns。注意check参数的DataType,CodePage 和MappedColumnID。MappedColumnID就是参数在sqlcommand中的序号。

Verify that External Columns lists a column for each parameter in the SQL statement. The column names are Param_0, Param_1, and so on.

You should not change the column names. If you change the column names, Integration Services generates a validation error for the OLE DB Command transformation.

Also, you should not change the data type. The DataType property of each column is set to the correct data type.

DBParamInfoFlags 是一个Custom Properties,用于 匹配Oledb的DBPrarmflagsenum,DBParamInfoFlags 的值表示参数的特征。例如,值 1 指定参数为输入参数,而值 65 则指定参数为输入参数,数据类型是字符型,且可能包含空值,81指定参数为输入参数,参数的数据类型是int。

If External Columns lists no columns you must add them manually.

  • Click Add Column one time for each parameter in the SQL statement.

  • Update the column names to Param_0, Param_1, and so on.

  • Specify a value in the DBParamInfoFlags property. The value must match a value in the OLE DB DBPARAMFLAGSENUM enumeration. For more information, see the OLE DB reference documentation.

  • Specify the data type of the column and, depending on the data type, specify the code page, length, precision, and scale of the column.

  • To delete an unused parameter, select the parameter in External Columns, and then click Remove Column.

  • Click Column Mappings and map columns in the Available Input Columns list to parameters in the Available Destination Columns list.

在input columns中的属性

ExternalMetadataColumnID:指定input column的值要流向的external column的ID

MSDN对OLE DB Command transformation component的介绍如下:

The OLE DB Command transformation runs an SQL statement for each row in a data flow. For example, you can run an SQL statement that inserts, updates, or deletes rows in a database table.

You can configure the OLE DB Command Transformation in the following ways:

  • Provide the SQL statement that the transformation runs for each row.

  • Specify the number of seconds before the SQL statement times out.

  • Specify the default code page.

Typically, the SQL statement includes parameters. The parameter values are stored in external columns in the transformation input, and mapping an input column to an external column maps an input column to a parameter. For example, to locate rows in the DimProduct table by the value in their ProductKey column and then delete them, you can map the external column named Param_0 to the input column named ProductKey, and then run the SQL statement DELETE FROM DimProduct WHERE ProductKey = ?.. The OLE DB Command transformation provides the parameter names and you cannot modify them. The parameter names are Param_0, Param_1, and so on.

If you configure the OLE DB Command transformation by using the Advanced Editor dialog box, the parameters in the SQL statement may be mapped automatically to external columns in the transformation input, and the characteristics of each parameter defined, by clicking the Refresh button. However, if the OLE DB provider that the OLE DB Command transformation uses does not support deriving parameter information from the parameter, you must configure the external columns manually. This means that you must add a column for each parameter to the external input to the transformation, update the column names to use names like Param_0, specify the value of the DBParamInfoFlags property, and map the input columns that contain parameter values to the external columns.

The value of DBParamInfoFlags represents the characteristics of the parameter. For example, the value 1 specifies that the parameter is an input parameter, and the value 65 specifies that the parameter is an input parameter and may contain a null value. The values must match the values in the OLE DB DBPARAMFLAGSENUM enumeration. For more information, see the OLE DB reference documentation.

The OLE DB Command transformation includes the SQLCommand custom property. This property can be updated by a property expression when the package is loaded. For more information, see Integration Services (SSIS) Expressions, Use Property Expressions in Packages, and Transformation Custom Properties.

This transformation has one input, one regular output, and one error output.

OLE DB Command transformation 用法的更多相关文章

  1. ODBC、OLE DB、 ADO的区别

    转自:http://blog.csdn.net/yinjingjing198808/article/details/7665577 一.ODBC ODBC的由来 1992年Microsoft和Syba ...

  2. 【转载】OLE DB, ADO, ODBC关系与区别

    原文:OLE DB, ADO, ODBC关系与区别 OLE DB, ADO, ODBC 一. ODBC(Open Database Connectivity,开放数据库互连)是微软公司开放服务结构(W ...

  3. 【转】ODBC、OLE DB、 ADO的区别

    一.ODBC ODBC的由来 1992年Microsoft和Sybase.Digital共同制定了ODBC标准接口,以单一的ODBC API来存取各种不同的数据库.随后ODBC便获得了许多数据库厂商和 ...

  4. 链接服务器"(null)"的 OLE DB 访问接口 "Microsoft.Jet.OLEDB.4.0" 返回了消息 "未指定的错误"。[手稿]

    消息 7302,级别 16,状态 1,第 1 行 无法创建链接服务器 "(null)" 的 OLE DB 访问接口 "Microsoft.JET.OLEDB.4.0&qu ...

  5. ODBC、OLE DB、 ADO、ODAC、ODP.NET

    面对各式各样.越来越多的数据来源和访问需求.软件开发框架中一般都提供了统一的访问接口和方法,来屏蔽数据库底层差异. 各式各样的Provider提供者. ODBC(Open Database Conne ...

  6. [转]SSIS中OLE DB Source中如何执行Store Procedure 以得到源数据

    本文转自:http://www.cnblogs.com/michaelxu/archive/2009/10/16/1584284.html 有很多人喜欢在OLE DB Source中执行Store P ...

  7. [转]SSIS OLE DB Source中执行带参数的存储过程

    本文转自:http://www.cnblogs.com/michaelxu/archive/2009/10/21/1587450.html 问题描述:执行一个存储过程得到一个多条记录的结果集,然后循环 ...

  8. [转]Mapping Stored Procedure Parameters in SSIS OLE DB Source Editor

    本文转自:http://geekswithblogs.net/stun/archive/2009/03/05/mapping-stored-procedure-parameters-in-ssis-o ...

  9. (4.3)ODBC/OLE DB/ADO概念与使用情况

    一.ODBC   ODBC的由来 1992年Microsoft和Sybase.Digital共同制定了ODBC标准接口,以单一的ODBC API来存取各种不同的数据库.随后ODBC便获得了许多数据库厂 ...

随机推荐

  1. Java随机生成18位身份证号

    package com.ihome.data; import java.text.SimpleDateFormat; import java.util.Calendar; import java.ut ...

  2. 采用Lambda表达式快速实现实体模型对象转换到DTO

    在项目中,采用code first时建立的模型对象不能直接用于数据传输,需要从新根据需求建立Dto对象 为什么需要建立Dto对象呢? DTO即数据传输对象.之前不明白有些框架中为什么要专门定义DTO来 ...

  3. [译]App Framework 2.1 (2)之 Get Involved

    App Framework  API 第二篇 原文在此:http://app-framework-software.intel.com/documentation.php#intro/involved ...

  4. BZOJ4596: [Shoi2016]黑暗前的幻想乡

    Description 四年一度的幻想乡大选开始了,最近幻想乡最大的问题是很多来历不明的妖 怪涌入了幻想乡,扰乱了幻想乡昔日的秩序.但是幻想乡的建制派妖怪(人类) 博丽灵梦和八云紫等人整日高谈所有妖怪 ...

  5. WPF上传文件到服务器

    利用WebClient 上传文件到服务器 创建一个空网站,创建一个UploadFile.aspx项, 服务器报500错误:检查文件保存路径是否存在,检查文件大小限制 protected void Pa ...

  6. Tomcat7 配置 ssl

    运行一个配置了ssl的项目时tomcat总是启动不成功,报错:“requires the APR/native library which is not available”,后来发现是找不到apr的 ...

  7. css解决display:inline-block;产生的缝隙(间隙)

    今天在做H5的水平滑动卡片时用到了display:inline-block;却发现处在同一水平线上的元素之间居然产生了缝隙,这很显然不是我想要的效果,所以我就换成了左浮动,这样缝隙的问题是解决了,但是 ...

  8. Java中9种IO的读取方式

    数据的读写,按照数据类型可以分为两种:字符流和字节流(二者区别?).所以数据读取方式按照数据类型也可以分为两类:字节流的读取和字符流的读取. 一.字节流读取操作: |  | |-----1.FileI ...

  9. vector、list、deque三者比较

    1.vector是一段连续的内存块,而deque是多个连续的内存块,list是所有数据元素分开保存,可以是任何两个元素都没有连续. 2.vector的查询性能最好,并且的末端增加数据也很好,除非它重新 ...

  10. Map Network Driver

    K: \\10.11.80.5\deptfiling-pubgz$ O: \\10.11.80.5\deptfiling-itdgz$