SSIS Foreach 循环文件夹作为变量

发布于 2024-10-27 16:10:07 字数 703 浏览 2 评论 0原文

我需要将 Foreach 循环中的文件夹设置为可变位置。我尝试将位置添加到我的包配置中,它的表现就像它工作一样,但是当我打开配置文件时,它不在那里。

我将其设置为 Foreach File Enumerator,并对路径进行硬编码,并检索完全限定的文件名。我的变量 Mappings 有一个索引为 0 的变量 CurrentFile。

因此,我将其更改为 Foreach From Variable Enumerator,SourceFiles 变量为 \server\path*.*。但现在它抱怨 CurrentFile,分配的值的类型与变量类型(字符串)不同。

我猜我需要以某种方式将表达式与“集合”选项卡上的枚举器一起使用?如何?

  • 一般:Foreach 循环容器
  • 集合:Foreach From Varialbe 枚举器;变量是 User::SourcePath;表达式(未使用)
  • 变量映射:变量 User::CurrentFile,索引 0
  • 表达式:(未使用)

错误:MyPackage 处的 0xC001F009:分配给变量“User::CurrentFile”的值类型与当前变量类型不同。变量在执行期间不能改变类型。变量类型是严格的,但 Object 类型的变量除外。 错误:Foreach 循环容器处的 0xC001C012:无法应用 ForEach 变量将编号 1 映射到变量“User::CurrentFile”。

I need to set the Folder in my Foreach loop to a variable location. I tried just adding the location to my package configuration, and it acted like it worked, but when I opened the configuration file, it wasn't there.

I had it set to Foreach File Enumerator, with the path hardcoded, and Retrieve fully qualified file name. My variable Mappings have a variable CurrentFile with index 0.

So, I've changed it to a Foreach From Variable Enumerator, with a SourceFiles variable of \server\path*.*. But now it's complaining about that CurrentFile, that the type of value being assigned differs from the variable type (string).

I'm guessing that I need to somehow use the Expressions with the Enumerator on the Collections tab? How?

  • General: Foreach Loop Container
  • Collection: Foreach From Varialbe Enumerator; Variable is User::SourcePath; Expressions (not used)
  • Variable Mappings: Variable User::CurrentFile, Index 0
  • Expressions: (not used)

Error: 0xC001F009 at MyPackage: The type of the value being assigned to variable "User::CurrentFile" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.
Error: 0xC001C012 at Foreach Loop Container: ForEach Variable Mapping number 1 to variable "User::CurrentFile" cannot be applied.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠栀 2024-11-03 16:10:07

一位同事向我展示了如何让它发挥作用。不要将其更改为“Foreach from Variable Enumerator”,而是将其保留为“Foreach File Enumerator”。

  • 集合:Foreach 文件枚举器;将文件夹和文件放入枚举器配置中。在“表达式”下,将“目录”设置为指向该目录的用户变量(它将优先于您输入的文件夹);将 FileSpec 设置为指向文件的用户变量(它将优先于您输入的文件)。
目录@[User::SourcePath](值:\\server\directory)
FileSpec @[User::CopyFileName](值:*.*)
  • 变量映射:变量 User::Current File,索引 0
  • 表达式:(未使用)

A co-worker showed me how to get it to work. Do NOT change it to "Foreach from Variable Enumerator", but leave it as "Foreach File Enumerator".

  • Collection: Foreach File Enumerator; put in a folder and files in the Enumerator configuration. Under Expressions, set the Directory to a user variable pointing to the directory (it will take precedence to the folder you've entered); set the FileSpec to a user variable pointing to the files (which will take precendence to the Files you've entered).
Directory @[User::SourcePath]  (value: \\server\directory)
FileSpec @[User::CopyFileName] (value: *.*)
  • Variable Mappings: Variable User::Current File, index 0
  • Expressions: (not used)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文