Avatar of UnderSeven
UnderSeven
 asked on

Type of value error in ssis package

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
Microsoft SQL ServerMicrosoft SQL Server 2008SSIS

Avatar of undefined
Last Comment
UnderSeven

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Jim Horn

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
UnderSeven

ASKER
That was it, once I normalized the output to all come from the same (explicit type) place it worked.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy