Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete statement fails when called from SSIS

I'm trying to orchestrate Snowflake from SSIS.

I'm using an ODBC connection and the execute SQL Task. A truncate table statement works fine and the task completes successfully. Changing this to a delete, the task fails with the below error:

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.

I can see from the snowflake query history that the query completed successfully:

enter image description here

I suspected that the "results" look to SSIS like a resultset when it was set to expect "none". I've changed this to both single row and "full Result set" into an object, but still get errors regardless of the setting.

What do I need to change in order to get SSIS to execute statements against Snowflake successfully?

Edit:

Adding my delete statement:

delete from SUMMARY.Data_minutes
where date >= dateadd(day,-5  ,'2019-01-20' )
and date <= '2019-01-20' 
like image 623
Neil P Avatar asked Mar 05 '19 10:03

Neil P


People also ask

Why is my SSIS package failing?

Reasons that the package may have failed are as follows: The user account that is used to run the package under SQL Server Agent differs from the original package author. The user account does not have the required permissions to make connections or to access resources outside the SSIS package.

How do you troubleshoot a failed package in SSIS?

The main techniques for troubleshooting deployed packages are as follows: Catch and handle package errors by using event handlers. Capture bad data by using error outputs. Track the steps of package execution by using logging.

How can I manually fail a package in Integration Services?

You need to make property FailPackageOnFailure true.. try to retrieve the property FailPackageOnFailure of the particular task and assign the value true. so that package will be failed.


1 Answers

Trying to figure out the issue

While searching for this issue i found something interesting at this Devart support page where similar issue was reported:

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.

Based on 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.

Which means that when no rows are matching the following condition it will throw an exception (in a similar case: ODBC version conflict):

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

Something to try

I cannot test this workarounds right now, but you can try two method:

  1. add a dummy select row after the delete command

     delete from SUMMARY.Data_minutes
     where date >= dateadd(day,-5  ,'2019-01-20' )
     and date <= '2019-01-20' 
    
     select 1
    
  2. create a stored procedure and pass the date as parameters, and execute it from the Execute SQL Task (also try to add a dummy select command at the end of the stored procedure)

      Exec sp_Delete ?
    
like image 147
Hadi Avatar answered Sep 23 '22 00:09

Hadi