gpt4 book ai didi

sql-server - 无法获得约束以在 ForEach 循环中处理 SQL 任务

转载 作者:行者123 更新时间:2023-12-02 02:44:34 25 4
gpt4 key购买 nike

我正在尝试执行一个非常基本的过程:

  • (重置)截断表
  • 遍历文件夹
  • 检查 FILES 表中是否存在 FileName
  • 如果没有,将文件中的数据导入数据表
  • 将 FileName 插入 FILES 表

我可以让它遍历文件文件夹,加载它们,并将文件名插入表中。但是,我无法使约束起作用,因此它只加载 FILES 表中不存在的文件。

这是我的整体设置:

enter image description here

变量:

enter image description here

这是 ForEach 循环设置:

enter image description here enter image description here

“文件存在于表中”SQL 任务:

enter image description here enter image description here enter image description here

我试过:

SELECT COUNT(id) as id FROM PORG_Files WHERE filename = ?

我还尝试了一个 SqlStatementSource 表达式:

"SELECT COUNT(id) as id FROM PORG_Files WHERE filename = '" + @[User::CurrentFileName] + "'"

但在使用表达式时,我不确定如何处理 General 下的 SQLStatement。

这是似乎总是为真的约束:

enter image description here

我认为问题出在变量具有双\s 的路径格式上,但是用 REPLACE 来更正它,它不起作用。

为了更好地衡量,这里是“将文件插入表”SQL 任务:

enter image description here enter image description here enter image description here

文件插入到表中就好了,这是表的样子:

enter image description here

我到底做错了什么?!?!

谢谢!!

最佳答案

您是否尝试过将 ResultName id 更改为 0

你可以看看documentation以供引用。 enter image description here

关于sql-server - 无法获得约束以在 ForEach 循环中处理 SQL 任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56289339/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com