优先级约束

发布于 2024-11-16 06:54:28 字数 405 浏览 0 评论 0原文

我创建了一个包,用于使用 FTP 任务从 FTP 提取 Excel 文件,然后将 Excel 文件处理到 SQL 数据库。从 FTP 拉取后,Excel 将存储在文件夹中。我将文件路径存储在一个变量中,并在优先级约束中给出了一个条件,以检查该文件是否存在于文件夹中。仅当文件路径存在时才执行 Excel 处理任务。但似乎即使该文件不存在,包也会执行,这会失败。所以我想检查一下我给出的条件是否错误。我在优先级约束中给出的条件如下:

@[User::FilePath] != ""

其中 @[User::FilePath] 包含文件路径,即 C:\FTPDestination\FileName.xlsx

是上述条件不正确?给出的正确条件是什么?

I have created a package to pull a excel file from FTP using FTP Task and then process the Excel file to SQL Database. After pulling from FTP, the excel will be stored in a folder. And I have stored the File path in a variable, and had given a condition in the Precedence costraint, to check whether the file exists in the folder or not. The excel processing task should be executed only if the file path exists. But it seems that even the file does not exist, the package executes, which will fail. So I wanted to check whether the condition I had given was wrong or not. The condition I had given in the precedence constraint was as follows :

@[User::FilePath] != ""

where @[User::FilePath] contains the file path ie C:\FTPDestination\FileName.xlsx

Is the above condition incorrect ? What is the correct condition to be given ?

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

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

发布评论

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

评论(1

桃酥萝莉 2024-11-23 06:54:28

使用条件 @[User::FilePath] != "" 无助于验证文件是否存在。此条件仅检查字符串变量 FilePath 是否为空字符串。

您可以使用以下一个选项来实现您的要求。您可以放置​​一个 Foreach 循环容器 来循环访问给定文件夹中的文件。

  1. 配置 SSIS 包,如屏幕截图 #1 所示。放置 FTP 任务Foreach 循环容器,任何任务都可以放置在 Foreach 循环容器内。

  2. 创建 4 个变量,如屏幕截图 #2 所示。 FTPPath包含下载FTP文件的路径; FolderPath 包含保存文件的文件夹; FileExtension 是应匹配以在 Foreach 循环容器内循环的文件; FilePath 将是将在 Foreach 循环容器中循环的每个文件的路径。

  3. 配置 FTP 任务,如屏幕截图 #3 和 #4 所示。

  4. 配置 Foreach 循环容器,如 scrteenshots #5 和 #6 中所示。

  5. 文件从 FTP 成功下载到目标文件夹时的屏幕截图 #7

  6. 屏幕截图 #8 显示在 FTP 文件夹中未找到匹配文件时的情况。如果您不希望 FTP 任务在找不到文件时失败,请参考我的答案 此堆栈溢出问题

希望有帮助。

屏幕截图 #1:

1

屏幕截图 #2:

2

屏幕截图 #3:

3

屏幕截图 #4:

4

屏幕截图 #5:

5

屏幕截图 #6:

6

屏幕截图 #7:

7

屏幕截图 #8:< /strong>

8

Using the condition @[User::FilePath] != "" doesn't help to validate if the file exist or not. This condition will only check if the string variable FilePath is an empty string or not.

Here is a possible option that you could use to achieve your requirements. You can place a Foreach loop container to loop through files in a given folder.

  1. Configure the SSIS package as shown in screenshot #1. Place an FTP task, Foreach loop container and any tasks can be placed inside the Foreach loop container.

  2. Create 4 variables as shown in screenshot #2. FTPPath contains the path to download the FTP files; FolderPath contains the folder to save the files to; FileExtension is the files that should be matched to loop through within the Foreach loop container; and FilePath will be the path of each file that will be looped through in Foreach loop container.

  3. Configure the FTP task as shown in screenshots #3 and #4.

  4. Configure the Foreach loop container as shown in scrteenshots #5 and #6.

  5. Screenshot #7 when a file is successfully downloaded from FTP to the destination folder.

  6. Screenshot #8 shows when no matching file is found in FTP folder. If you don't want the FTP task to fail when no files are found, then refer my answer in this Stack Overflow question.

Hope that helps.

Screenshot #1:

1

Screenshot #2:

2

Screenshot #3:

3

Screenshot #4:

4

Screenshot #5:

5

Screenshot #6:

6

Screenshot #7:

7

Screenshot #8:

8

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文