SSIS 文件系统任务错误:分配给变量的值的类型...与当前变量类型不同 [英] SSIS File System Task error: The type of the value being assigned to variable ... differs from the current variable type

查看:42
本文介绍了SSIS 文件系统任务错误:分配给变量的值的类型...与当前变量类型不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的...我有一个相对简单的 SSIS 包(DTSDesigner100,Visual Studio 2008 版本 9.0.30729.4462 QFE,.NET Framework 3.5 SP1).包的 SSIS 控制流的末尾是一个文件系统任务,它是一个重命名文件操作.

OK... I have a relatively simple SSIS package (DTSDesigner100, Visual Studio 2008 Version 9.0.30729.4462 QFE, .NET Framework 3.5 SP1). At the end of the SSIS control flow for the package is a File System Task which is a Rename File operation.

这个文件系统任务的属性如下:

The properties of this File System Task are as follows:

  • IsDetinationPathVariable:真
  • 目标变量:用户::输出文件名
  • 覆盖目的地:真
  • 描述:文件系统任务
  • 操作:重命名文件
  • IsSourcePathVariable:错误
  • SourceConnection:Excel 模板复制目标

没有定义的表达式.如您所见,我将 Destination 分配为变量 User::OutputFileName.所以让我们看看那个变量...

There are no defined expressions. As you can see, I have the Destination assigned as a variable User::OutputFileName. So let's look at that variable...

  • 名称:输出文件名
  • 范围:包
  • 数据类型(ValueType):字符串
  • 值:
  • 命名空间:用户
  • EvaluateAsExpression:真
  • 只读:错误
  • 表达:(见下文)

.

"\\\\SERVER\\Folder\\" + "MyAwesomeExcelWorkbook_"
+ (DT_WSTR,4)DATEPART("year", GETDATE())+ "-"
+ RIGHT("0" + (DT_WSTR,2)DATEPART("mm", GETDATE()), 2) + "-"
+ RIGHT("0" + (DT_WSTR,2)DATEPART("dd", GETDATE()), 2) + "-"
+ RIGHT("0" + (DT_WSTR,2)DATEPART("hh", GETDATE()), 2) + "-"
+ RIGHT("0" + (DT_WSTR,2)DATEPART("mi", GETDATE()), 2) + "-"
+ RIGHT("0" + (DT_WSTR,2)DATEPART("ss", GETDATE()), 2)
+ ".xlsx"

所以我可以成功地评估这个表达式.每次包运行(和失败)时,它的 Value 就是所计算的表达式的值,正如人们所期望的那样.

So I can Evaluate this expression successfully. Every time the package runs (and fails) its Value is the value of the evaluated expression, as one would expect.

当我运行程序包时,会发生以下情况...

When I run the package, here's what happens...

  1. 前面的步骤运行成功.
  2. 文件系统任务启动,文件重命名成功.
  3. 但是,由于文件系统任务失败并出现以下错误,因此包现在失败了:

.

Error: 0xC001F009 at Package: The type of the value being assigned to variable "User::OutputFileName" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.
Task failed: Rename Excel Workbook
Error: 0xC0019001 at Rename Excel Workbook: The wrapper was unable to set the value of the variable specified in the ExecutionValueVariable property.
Warning: 0x80019002 at Package: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED.  The Execution method succeeded, but the number of errors raised (4) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
SSIS package "Package.dtsx" finished: Failure.

这里显然有一些小细节我忘记了.现在,我已经尝试将整个表达式转换为 DT_WSTR,512 —— 计算结果很好,但文件系统任务仍然会失败并出现相同的错误.

There is apparently some minor detail I am forgetting here. Now, I've tried casting the entire expression as a DT_WSTR,512 -- that evaluates just fine, but the File System Task will still fail with the same error.

谁能指出我忽略的细节?提前致谢.

Anyone who can point out the detail(s) I'm overlooking? Thanks in advance.

推荐答案

问题是变量的作用域是包,而不是任务.
将变量范围更改为任务会导致成功执行.

The issue is the variable is scoped to the Package, and not the task.
Changing the variable to be scoped to the task results in successful execution.

我想我需要问——为什么?老实说,这与我对 SSIS 的理解不符——自从它通过每个 Denali CTP 引入以来,我一直在使用它.到底发生了什么导致任务范围的变量变得笨拙,而不是包范围的变量在文件系统任务中使用?在某些任务之外没有问题,但是当我在某些任务中使用它们时会出现问题.怎么回事?

I figured I need to ask -- why? This honestly doesn't jibe with my understanding of SSIS -- which I've used since its introduction through every Denali CTP. What is going on under the hood that results in this being hunky-dory for task-scoped variables, but not package scoped ones that get used in a File System Task? Outside of certain tasks there's no issue, but there is one when I use them in certain tasks. What's going on?

这篇关于SSIS 文件系统任务错误:分配给变量的值的类型...与当前变量类型不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆