在 For Each 循环容器中的不同点使用参数

Using Parameters at different points within For Each Loop Container

我在控制流中有以下步骤,其中第一个执行 SQL 任务使用 WorkOrderID,第二个脚本任务使用 InvoiceID。

任何人都可以发现我在下面做错了什么,因为它在更新发票状态对象上失败了吗?

[Execute SQL Task] Error: Executing the query "Update I Set I.Status = CASE WHEN C1.Name = 'Cy..." failed with the following error: "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

更新发票状态对象的查询是:

Update
    I
 Set
    I.Status = 10
from
    Invoice I 
where 
    I.ID  = ?

正在检查数据类型和参数名称/顺序

我认为错误是由可变数据类型引起的。检查 User::WorkerID 是否为 VARCHAR 类型,同时它必须是整数。检查变量的数据类型是否与列相关。

基于以下文章Resolving an SSIS Error Due to Parameters Not Mapped Correctly

Other reasons this particular error could come up is if your Data Type is set incorrectly, or if the number of query parameters don’t match the variables mapped (and in the correct order).

还有为什么 InvoiceID 参数名称是 1 而不是 0?尝试将其改回 0


解决方法

如果参数有问题,可以使用Expression构建SQL语句:

转到 Execute SQL Task 编辑器中的表达式。 Select SQLStatmentSource 属性 并写出类似的表达式:

"Update
    I
Set
    I.Status = 10
from
    Invoice I 
where 
    I.ID  = " + (DT_WSTR,50)@[User::InvoiceID]