2016-08-26 18 views
1

誰かがこの問題で私を助けることができますか?私はSSISでsprocを呼び出しています。新しいレコードが更新されたりテーブルに挿入されたりすると、ファイルを作成するだけです。そのテーブルは、別のソーステーブルをチェックして、そのテーブルで変更されたものがあるかどうかを確認し、コピーテーブルに追加します。ソーステーブルの更新や変更があれば、ファイルを作成します。何をするにも。SQLコマンドに基づく行セットがOLE DBプロバイダによって返されませんでした

私はロジックをテストしましたが、すべてうまくいくようですが、SSISでsprocを実行しようとすると、「SQLコマンドに基づく行セットはOLE DBプロバイダから返されませんでした」というエラーメッセージが表示されます。当初は、返される行がないためにエラーが発生していることを意味していましたが、返された行があっても同じエラーメッセージが表示されます。クエリを解析してSSISで結果をプレビューできますが、実行時にはまだ赤色に変わり、そのエラーメッセージが表示されます。

以下は私のsprocのコードです。どんな助けやアイデアも感謝しています!

USE [dev02] 
    GO 
    /****** Object: StoredProcedure [dbo].[usp_VoidReasons] Script Date:   8/25/2016 11:54:44 AM ******/ 
    SET ANSI_NULLS ON 
    GO 
    SET QUOTED_IDENTIFIER ON 
    GO 
    /*-------------------------------------------------------------------------- ---- 
    Author:   Andrej Friedman 
    Create date: 07/27/2016 
    Description: This sproc assists SSIS in creating a file but only when a     new row has been added to the VoidReasonsLookup table 
    that didnt exist there before or if the code or description has changed in that table. The table is compared to the prod1.dbo.miscde 
table for diferences and only for the Void Reasons of that table (mcmspf = 'cv'). 
History:   
SampleCall:  EXEC [dbo].[usp_VoidReasons] 
    --truncate table dev02.dbo.VoidReasonsLookup 
    --select * from dbo.VoidReasonsLookup 
    --update VoidReasonsLookup set Description = 'BB' where Description = 'BENEFIT CODE ADJUSTMENT' 
------------------------------------------------------------------------------*/ 


ALTER proc [dbo].[usp_VoidReasons] 

as 


declare @ImportDate as date = CONVERT (date, GETDATE()) 


insert into VoidReasonsLookup (Code, [Description]) 


--Change #1 -- New Code and Description 

--This will insert a new row in the VoidReasons table where the Code and description doesnt exist there but exists in the source table. 

select (M.mcmscd_1 + M.mcmscd_4) as Code, mcmsds as [Description] from prod1.dbo.miscde M 

left join VoidReasonsLookup VL 

on M.mcmscd_1 + M.mcmscd_4 = VL.Code 

where M.mcmspf = 'cv' 

and VL.Code is null 



--Change #2 -- Code dropped off source table so we need it gone from the VoidReasons table 

--This will delete rows where the Code doesnt exists in the source table any longer 


delete from VL from VoidReasonsLookup as VL 

left join prod1.dbo.miscde as M 

on VL.Code = M.mcmscd_1 + M.mcmscd_4 

where M.mcmscd_1 + M.mcmscd_4 is null 


--Change #3 -- Description has changed for a certain code in the source table. 

--This will update the Description to the source table if it is different in the VoidReasons table and update the ImportDate to today when that update took place. 


update VL 

set VL.[Description] = M.mcmsds, 

VL.ImportDate = @ImportDate 

from dbo.VoidReasonsLookup as VL 

join prod1.dbo.miscde as M 

on VL.Code = M.mcmscd_1 + M.mcmscd_4 

where VL.[Description] <> M.mcmsds 

and M.mcmspf = 'cv' 




--This will give back everything in the VoidReasons table but only if todays date is the same as the ImportDate column of the table. 

--This will mean that today a record was inserted or updated. 


If exists(select ImportDate from VoidReasonsLookup 

where ImportDate = @ImportDate) 

select * from VoidReasonsLookup 

else 

print 'no changes detected in VoidReasons table' 

答えて

0

すべてをコメントアウトして、もう一度エラーを報告してください。エラーが発生するまで部品のコメントを外します。エラーが発生すると、問題の原因を知ることができます。

+0

あなたはSSMSを意味していますか? SSMSでは、ストアドプロシージャはうまく動作し、ロジックは良いようです。エラーなしで実行されないSSISだけです。 – LightChild77

1

SET NO NOUNTをONにし、最後に条件に基づいて結果セットを選択すると、SSISは設定した出力タイプに基づいて常に結果セットを期待します。出力が問題を解決するように空の結果セットを使用することができます

+0

ありがとうございます。私は完全に理解しているか分からない。空の結果セットを処理するようにSSISに指示すればいいでしょうか?結果が返っても、SSISはまだエラーがあります。 – LightChild77

関連する問題