【发布时间】:2020-11-30 08:18:31
【问题描述】:
我正在尝试使用 SSIS 脚本组件来转换我的输入数据,同时使用此博客中描述的方法: https://blog.theobald-software.com/2010/09/20/building-ssis-package-with-xtract-is-table-programmatically/
一切正常,我已经创建了源组件和目标组件,但我不知道如何使用代码的映射部分将我的输入列转换为所需的格式(如下所述)
//map the columns
IDTSPath100 path = dataFlowMainPipe.PathCollection.New();
path.AttachPathAndPropagateNotifications(DataSource.OutputCollection[0], OLEDBDestination.InputCollection[0]);
IDTSInput100 input = OLEDBDestination.InputCollection[0];
IDTSVirtualInput100 vInput = input.GetVirtualInput();
foreach (IDTSVirtualInputColumn100 vColumn in vInput.VirtualInputColumnCollection)
{
IDTSInputColumn100 vCol = InstanceDestination.SetUsageType(input.ID, vInput, vColumn.LineageID, DTSUsageType.UT_READWRITE);
InstanceDestination.MapInputColumn(input.ID, vCol.ID, input.ExternalMetadataColumnCollection[vColumn.Name].ID);
代码中有一个从输入到输出的 1:1 映射,但我需要将前 1..n-1 列从输入映射到输出中的 4 列,并将行数乘以 (n-1 )*input.CountRows,见下例
输入
Al _1 _2 _3 _4 _5 _6 Value
a A 5a 4a 2oa 5oa 4oa 10
b B 5b 4b 2ob 5ob 4ob 20
c C 5c 4c 2oc 5oc 4oc 30
d D 5d 4d 2od 5od 4od 40
e E 5e 4e 2oe 5oe 4oe 50
f F 5f 4f 2of 5of 4of 60
输出
N P Key Value
Al _1 a A
Al _1 b B
Al _1 c C
Al _1 d D
Al _1 e E
Al _1 f F
Al _2 a 5a
Al _2 b 5b
Al _2 c 5c
Al _2 d 5d
Al _2 e 5e
Al _2 f 5f
Al _3 a 4a
Al … … …
我使用 Script 组件作为 Source,整个代码在 PreExecute 阶段执行。
非常感谢您的任何建议 BR 回复
【问题讨论】:
标签: c# ssis components transformation