Solved

Type of value error in ssis package

Posted on 2014-01-14
2
331 Views
Last Modified: 2016-02-10
I have an ssis execute sql task step

It calls a stored procedure and attempts to dump the output into a user variable of type double.

It is getting a error thrown about not being able to change types mid execution if the result of the stored procedure is zero (I think).

The best way I could troubleshoot this is manually run the stored procedure.  I hard coded the store procedure to act as follows:

declare @array as table(statement float)
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	IF @StatementDocNo = 0
		BEGIN
			SELECT 0 AS [Amount Due]
		END
	ELSE
		BEGIN
			-- Insert statements for procedure here
insert into @array
			SELECT DISTINCT -- select top 10 * from umcr2100
				isnull(util..UMCR2102.umAmount1,0)  AS [Discounted Amount Due]
			FROM
				util..UMCR2100
				INNER JOIN util..UMCR2102 ON util..UMCR2100.umStatementDocNo = util..UMCR2102.umStatementDocNo
			WHERE
				(util..UMCR2100.umStatementDocNo = @StatementDocNo)
				AND
				umDescription1 LIKE 'Total Amount Due%'
		
		IF @@ROWCOUNT = 0
		BEGIN
			SELECT 0 AS [Amount Due]
		END
		ELSE
		BEGIN
		 select * from @array
		END
END

Open in new window


I do not see how it is possible for the code above to throw anything not compatible with a double.  

How can I troubleshoot this/ make this work.

(The output almost always comes out to greater than zero and has a decimal).

This is written in sqlsvr 2008
0
Comment
Question by:UnderSeven
2 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
Comment Utility
>SELECT 0 AS [Amount Due]
>SELECT DISTINCT ... AS [Discounted Amount Due]
>SELECT 0 AS [Amount Due]
>select * from @array

For starters, SSIS likes to create a 'contract' between it and a source of data so that it knows what schema to expect, so it can to map columns.  In your case, this means the SQL Task can't handle calling a SP where the return set is not the same schema each and every time.

You'll need to change the above four SELECTs so that it is the same exact schema.
Even better would be to only have one SELECT.
0
 

Author Closing Comment

by:UnderSeven
Comment Utility
That was it, once I normalized the output to all come from the same (explicit type) place it worked.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

My client sends a request to me that they want me to load data, which will be returned by Web Service APIs, and do some transformation before importing to database. In this article, I will provide an approach to load data with Web Service Task and X…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now