从 SSIS 调用时删除语句失败

Delete statement fails when called from SSIS

我正在尝试从 SSIS 编排 Snowflake。

我正在使用 ODBC 连接和执行 SQL 任务。 truncate table 语句工作正常并且任务成功完成。将其更改为删除,任务失败并出现以下错误:

failed with the following error: "Error HRESULT E_FAIL has been returned from a call to a COM component.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

从雪花查询历史可以看出查询成功完成:

我怀疑 "results" 将 SSIS 设置为期望 "none" 时,它看起来像一个结果集。我已将其更改为单行并将 "full Result set" 更改为一个对象,但无论设置如何,仍然会出现错误。

我需要更改什么才能让 SSIS 成功执行针对 Snowflake 的语句?

编辑:

添加我的删除语句:

delete from SUMMARY.Data_minutes
where date >= dateadd(day,-5  ,'2019-01-20' )
and date <= '2019-01-20' 

正在尝试找出问题所在

在搜索此问题时,我在 Devart support page 发现了一些有趣的内容,其中报告了类似的问题:

According to Microsoft documentation if the query has not affected any records will return the result SQL_NO_DATA (for the ODBC 3.x specification). Our driver and SSIS use the ODBC 3.x specification, however, in the described case,SSIS implements the behavior as ODBC 2.x . That's why, when the result of SQL_NO_DATA is received, the error "Error HRESULT E_FAIL has been returned from a call to a COM component" is returned.

基于Microsoft documentation

When an ODBC 3.x application calls SQLExecDirect, SQLExecute, or SQLParamData in an ODBC 2.x driver to execute a searched update or delete statement that does not affect any rows at the data source, the driver should return SQL_SUCCESS, not SQL_NO_DATA. When an ODBC 2.x or ODBC 3.x application working with an ODBC 3.x driver calls SQLExecDirect, SQLExecute, or SQLParamData with the same result, the ODBC 3.x driver should return SQL_NO_DATA.

这意味着当没有行符合以下条件时,它将抛出异常(类似情况:ODBC 版本冲突):

where date >= dateadd(day,-5  ,'2019-01-20' )
and date <= '2019-01-20' 

尝试一下

我现在无法测试此解决方法,但您可以尝试两种方法:

  1. 在删除命令后添加一个虚拟 select 行

     delete from SUMMARY.Data_minutes
     where date >= dateadd(day,-5  ,'2019-01-20' )
     and date <= '2019-01-20' 
    
     select 1
    
  2. 创建一个存储过程并将日期作为参数传递,然后从执行 SQL 任务 中执行它(也尝试添加一个虚拟 select存储过程末尾的命令)

      Exec sp_Delete ?
    

我有同样的问题,为了解决我将连接提供程序从 ODBC 连接更改为 ADO.net 连接。

希望对你有用。