- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我创建了一个 SSIS 自定义数据流组件,该组件执行将日期从格式为 CYYMMDD 的 COBOL 大型机日期类型转换为 SQL Server 支持的格式 YYYYMMDD 的简单任务。存在错误行,因为传入的 COBOL 格式日期可能是无效日期(即 2-29-2015、4-31-2016、9-31-2010 等)。这些错误日期来自用户派生的输入字段,这些字段上没有日期掩码,我无法添加日期掩码,因为该应用程序属于第 3 方数据供应商。
Câu hỏi của tôi:
自定义组件不会重定向错误行。我在 MSDN 上找到了一篇解释如何重定向错误行的帖子:
https://msdn.microsoft.com/en-us/library/ms136009.aspx
我使用此代码作为指南并对其进行了修改以满足我能够在多个选定的输入列上执行的需要(MS 的示例仅考虑一个输入列)。当我执行该过程时,出现以下两个错误:
[ConvertCobolDates [2]] 错误:System.ArgumentException:值不在预期范围内。 在 Microsoft.SqlServer.Dts.Pipeline.Wrapper.IDTSBuffer100.DirectErrorRow(Int32 hRow,Int32 lOutputID,Int32 lErrorCode,Int32 lErrorColumn) 在 Microsoft.SqlServer.Dts.Pipeline.PipelineBuffer.DirectErrorRow(Int32 outputID,Int32 errorCode,Int32 errorColumn) 在 SSIS.Convert.CobolDate.DataFlow.ConvertCobolDateDataFlow.ProcessInput(Int32 inputID,PipelineBuffer 缓冲区) 在 Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostProcessInput(IDTSManagedComponentWrapper100 包装器、Int32 inputID、IDTSBuffer100 pDTSBuffer、IntPtr bufferWirePacket)[SSIS.Pipeline] 错误:SSIS 错误代码 DTS_E_PROCESSINPUTFAILED。组件“ConvertCobolDates”(2) 上的 ProcessInput 方法在处理输入“Input”(4) 时失败,错误代码为 0x80070057。标识的组件从 ProcessInput 方法返回错误。该错误特定于组件,但该错误是 fatal error ,将导致数据流任务停止运行。在此之前可能会发布错误消息,其中包含有关失败的更多信息。
此外,我不知道我是否缺少专门重定向输出的代码,或者错误处理是否未正确完成 - 它没有显示在“配置错误输出”屏幕中。非常感谢任何帮助! nhập mô tả hình ảnh ở đây
注意:我怀疑错误出在以下位置之一:ProvideComponentProperties 或 ProcessInput。
public override void ProvideComponentProperties()
{
thử
{
// Perform the base class' method
base.ProvideComponentProperties();
// Start out clean, remove anything put on by the base class
base.RemoveAllInputsOutputsAndCustomProperties();
// Set component information
ComponentMetaData.Name = "ConvertCobolDates";
ComponentMetaData.Description = "Data Flow task that converts COBOL date types into SQL Server Date types for each row flowing through the component.";
ComponentMetaData.ContactInfo = "Contact Info.";
ComponentMetaData.UsesDispositions = true; // As a rule, components should support error dispositions - they make it easier to troubleshoot problems with the data
// Create input objects. This allows the custom component to have a 'Success' input data flow line
IDTSInput100 input = ComponentMetaData.InputCollection.New();
input.Name = "Input";
input.ErrorRowDisposition = DTSRowDisposition.RD_RedirectRow; // Use RD_RedirectRow is ComponentMetaData.UsesDispositions = true. Otherwise, use RD_NotUsed
input.ErrorOrTruncationOperation = "Either a bad date has been detected or an input column(s) has been selected that does not contain dates.";
// Create output objects. This allows the custom component to have a 'Success' output data flow line
IDTSOutput100 output = ComponentMetaData.OutputCollection.New();
output.Name = "Output";
output.SynchronousInputID = input.ID; //Synchronous transformation
output.ExclusionGroup = 1;
// Create output objects. This allows the custom component to have a 'Error' output data flow line
IDTSOutput100 errorOutput = ComponentMetaData.OutputCollection.New();
errorOutput.IsErrorOut = true;
errorOutput.Name = "ErrorOutput";
errorOutput.SynchronousInputID = input.ID;
errorOutput.ExclusionGroup = 1;
}
catch (Exception ex)
{
bool bolCancel = false;
ComponentMetaData.FireError(0, ComponentMetaData.Name, ex.Message, "", 0, out bolCancel);
throw;
}
}
public override void ProcessInput(int inputID, PipelineBuffer buffer)
{
IDTSInput100 input = ComponentMetaData.InputCollection.GetObjectByID(inputID);
// This code assumes the component has two outputs, one the default,
// the other the error output. If the intErrorOutputIndex returned from GetErrorOutputInfo
// is 0, then the default output is the second output in the collection.
int intDefaultOutputID = -1;
int intErrorOutputID = -1;
int intErrorOutputIndex = -1;
int intErrorColumnIndex = -1;
bool bolValidDate = false;
GetErrorOutputInfo(ref intErrorOutputID, ref intErrorOutputIndex);
if (intErrorOutputIndex == 0)
intDefaultOutputID = ComponentMetaData.OutputCollection[1].ID;
khác
intDefaultOutputID = ComponentMetaData.OutputCollection[0].ID;
// Process each incoming row
while (buffer.NextRow())
{
thử
{
for (int i = 0; i < inputBufferColumnIndex.Length; i++)
{
if (!buffer.IsNull(inputBufferColumnIndex[i]))
{
// Get the name of the current column that is being processed
string strColName = this.ComponentMetaData.InputCollection[0].InputColumnCollection[i].Name;
// Get the current row number that is being processed
int intCurRow = buffer.CurrentRow + 2; // Buffer.CurrentRow is zero bounded and the first row is a header row, which is skipped. Adjust by two to account for this
// Ideally, your code should detect potential exceptions before they occur, rather
// than having a generic try/catch block such as this. However, because the error or truncation implementation is specific to each component,
// this sample focuses on actually directing the row, and not a single error or truncation.
// Get the ID of the PipelineBuffer column that may cause an error. This is required for redirecting error rows
intErrorColumnIndex = this.ComponentMetaData.InputCollection[0].InputColumnCollection[i].ID;
string strCobolDate = buffer.GetString(inputBufferColumnIndex[i]);
string strConvertedCobolDate = ConvertCobolDate(strCobolDate, strColName, intCurRow);
DateTime dtConvertedSQLDate;
// Validate that the date is correct. This detects bad dates (e.g., 2-30-2016, 4-31-2015, etc.) that are inputted from the user
// Throw an error if the date is bad
bolValidDate = DateTime.TryParse(strConvertedCobolDate, out dtConvertedSQLDate);
if (!bolValidDate)
{
// Validation failed, throw an exception and redirect the error row
throw new Exception();
}
else if (bolValidDate)
{
// validation passed. Direct the column back to its corresponding row within the pipeline buffer
buffer[inputBufferColumnIndex[i]] = dtConvertedSQLDate.ToShortDateString();
}
}
}
// Unless an exception occurs, direct the row to the default
buffer.DirectRow(intDefaultOutputID);
}
catch(Exception)
{
// Has the user specified to redirect the row?
if (input.ErrorRowDisposition == DTSRowDisposition.RD_RedirectRow)
{
// Yes, direct the row to the error output.
buffer.DirectErrorRow(intErrorOutputID, 0, intErrorColumnIndex);
}
else if (input.ErrorRowDisposition == DTSRowDisposition.RD_FailComponent || input.ErrorRowDisposition == DTSRowDisposition.RD_NotUsed)
{
// No, the user specified to fail the component, or the error row disposition was not set.
throw new Exception("An error occurred, and the DTSRowDisposition is either not set, or is set to fail component.");
}
khác
{
// No, the user specified to ignore the failure so direct the row to the default output.
buffer.DirectRow(intDefaultOutputID);
}
}
}
}
1 Câu trả lời
经过一些艰苦的研究和 friend 的帮助,问题已经确定 - 传递给 DirectErrorRow 函数的 errorCode 0(在我之前发布的 MSDN 文章中指定)不正确 [它实际上是一个负数(在这种情况下:-1071628258)]。这是一个很难修复的错误,因为编译器在没有指定超出范围的参数和值的情况下输出一般性越界错误(见下文)。
我认为编译器错误指的是它无法转换的实际错误日期,因此我将所有时间都花在了 intErrorColumnIndex 上,MSDN 文章将其列为:
我假设 Microsoft 提供的错误代码 0 是正确的。凭直觉,我的 friend 说尝试检索实际的错误代码并且成功了!因此,errorCode 可能在负无穷大到 -1 之间的某处。微软关于定向错误行的 MSDN 文章需要更正。
我:1
微软:0
解决方法在catch block 中如下:
catch(Exception)
{
// Has the user specified to redirect the row?
if (input.ErrorRowDisposition == DTSRowDisposition.RD_RedirectRow)
{
// Yes, get the error code
int DTS_E_ERRORTRIGGEREDREDIRECTION = -1;
unchecked
{
DTS_E_ERRORTRIGGEREDREDIRECTION = (int)0xC020401E;
}
// Direct the row to the error output
buffer.DirectErrorRow(intErrorOutputID, DTS_E_ERRORTRIGGEREDREDIRECTION, intErrorColumnIndex);
}
else if (input.ErrorRowDisposition == DTSRowDisposition.RD_FailComponent || input.ErrorRowDisposition == DTSRowDisposition.RD_NotUsed)
{
// No, the user specified to fail the component, or the error row disposition was not set
throw new Exception("An error occurred, and the DTSRowDisposition is either not set or is set to fail component.");
}
khác
{
// No, the user specified to ignore the failure so direct the row to the default output
buffer.DirectRow(intDefaultOutputID);
}
}
关于c# - SSIS 自定义数据流组件 - 重定向错误行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36025891/
我有一些自定义控制流和数据流任务未显示在 SSIS 工具箱中。当我在 SSDT 中打开包含自定义任务的包时,加载该包时出现几个错误。 加载 MyModuleTemplate1.dtsx 时出错:由于错
我有一个现有的 SSIS 包 (load1),它将数据从一台服务器 (srv1) 加载到我的服务器 (srv2)。在我可以运行 load1 之前,还有 2 个其他负载需要在 srv1 上运行,然后 l
我有点困惑 async方法是否适用于 SSIS 作业。脚本任务项创建一个面向 .NET Framework 4.5 的 Visual Studio 项目,输出类型为类库。 如果我制作主要方法 publ
有没有一种方法可以在 SSIS 执行期间动态创建目标文件夹而不使用脚本任务,例如。我有代码 123、133、143,如果不存在,我想在下面创建一个文件夹位置 D:\Outbox\ACI\123 D:\
我需要执行 29 个 ssis 包。所以计划创建一个主包来执行所有这些包。我不知道如何实现这一点。能否请您简要解释一下。提前致谢 ! 最佳答案 这篇文章很好地概括了主包的功能,它基本上是一个在控制流中
我有一个像这种格式的字符串。就我而言,我只需要从字符串大小写中提取字符 1)12AB 2)SD12 3)1WE4 输出 1)AB 2)SD 3)WE 我只需要提取字符。我在 SSIS 包的派生列中使用
使用: Windows 7 企业版; Visual Studio Pro 2017 (15.3.5);固态硬盘 15.1 无法让数据查看器在我的 SSIS 包上弹出。我确实做了一些 Google-fu
我可以使用什么模式/通配符来分别获取以下两个文件?目前,我正在使用此模式 CRM#ContractsBillingAccount*.csv 但两个文件名都符合此模式。如何避免? CRM#Contrac
是否可以在脚本任务中将发生的异常重定向到另一个表/日志?如果是这样,该怎么做? 最佳答案 您可以在脚本任务中执行在 vb.net 或 C# 中可以执行的任何操作。但是如果你在一个脚本任务中做了这么多,
我使用 CSV 中的以下内容来测试 SCD。我认为它会识别 LocationID 并在必要时更新记录。但它没有。它只插入新记录。 我正在使用带有 Win 身份验证的 Visual Studio 201
我对 SSIS 事务隔离级别的问题很少。 考虑一个场景:我有一个执行 SQL 任务,它在表 A 中插入数据。这个任务指向一个数据流任务,它读取以前插入到 A 上的数据。我已经启动了分布式事务,如果我在
你好 我正在创建一个需要按指定顺序执行以下操作的 ssis 包: 1:处理一些数据 2:将该数据移动到其他一些表 3:获取一些数据并将其推送到纯文本文件中。 我为这些创建了 3 个存储过程,我为 1
使用SQLServer 2012 Enterprise,在“控制流”选项卡中单击鼠标右键时,在SSIS中看不到“程序包配置向导”。我可以看到所有其他项目(日志,数字签名...)。 以下是有关我的安装的
我有一个 Foreach 容器,其中有一个 执行进程任务 。我有很多 Console.WriteLine() 语句。 图像中突出显示的 3 个图像可用于从 .exe 获取输出。 我在包中声明了一个变量
SSIS 非常擅长处理所有记录都相同的平面文件,但当存在一点复杂性时就不太好了。 我想导入一个与此类似的文件 - Customer: 2344 Name: John Smith Item
当我在 SSIS 包 (ProtectionLevel) 上设置权限并输入 PackagePassword 时,当我在计算机上打开包时,它不会提示我输入密码。 我做错了吗? 最佳答案 你可能没有做错什
đóng cửa. Câu hỏi này không đáp ứng được hướng dẫn của Stack Overflow. Hiện tại câu hỏi này không chấp nhận câu trả lời. Bạn muốn cải thiện vấn đề này? Cập nhật câu hỏi để nó phù hợp với chủ đề của Stack Overflow. Đã đóng cửa cách đây 7 năm. Cải thiện điều này
我致力于创建 biml。从中生成 ssis 包。构建 SSIS 项目,然后在服务器上部署 ispac 文件。 但是这些所有手动步骤都可以自动化吗? 我可以使用命令行从 biml 生成 ssis 吗?除
我已经创建了一个 SSIS 包。如果包失败,我需要将事务应用于此包以进行回滚。我发现的是一个属性“TransactionOption”,它应该被赋予“Required”。我对吗 ?并且我已将包的 Tr
我在 Visual Studio 2015 中向 SSIS 添加自定义 SSIS 组件时遇到问题。 我的系统是:Windows 8.1 64 位 Visual Studio 社区 2015 版14.0
Tôi là một lập trình viên xuất sắc, rất giỏi!