Decimal places not returning from a stored procedure

I have a stored procedure which should be returning a percentage back to the ASP page.

The problem is it is rounding up to the nearest whole number and not returning the decimal places.


The relevant parts of the stored procedure are as follows(the variable used to return the percentage is @result4):

CREATE PROCEDURE sp_highlevelsummaryrpt

@result4 int output
AS
declare @discinc decimal


if (@discinc is null)
          begin
          set @discinc = '0'
     end

set @discinc = (select Approved_Disc_Inc from pr_misc)

set @result4 = @discinc
select @result4

In the ASP page, I am showing the variable on the page as follows:


result4 = cmd_Execute_stored_procedure.Parameters("@result4")

%><td><%Response.Write(formatnumber(result4,2))%></td><%

I have tried changing the data type in the stored to float, numeric but none work.

Can anyone help??
obichamAsked:
Who is Participating?
 
John844Commented:
whenyou tried changing the datatype as mentioned above, did you also change the datatype of your command parameter?
0
 
OtanaCommented:
you have declared your output variable (@result4) as an integer, therefore you will not get any decimalplaces returned.

try this: @return4 numeric(13,10)
0
 
OtanaCommented:
I meant @result4 off course, sorry...
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
obichamAuthor Commented:
That's a very good point but unfortunately it still doesn't work for some reason.

I tried declaring the output variable as decimal and a float but that won't work either
0
 
OtanaCommented:
set @discinc = (select Approved_Disc_Inc from pr_misc)

what type of field is Approved_Disc_Inc? And what does it contain?
0
 
obichamAuthor Commented:
It is decimal(5) and it contains the value 1.75
0
 
OtanaCommented:
select Approved_Disc_Inc from pr_misc

does this return a single value? or multiple records? can you post more of your stored procedure?
0
 
John844Commented:
does the stored procedure display the proper values when you run it from query analyser?

I would also change this line to avoid any future problems if more records are added.
set @discinc = (select Approved_Disc_Inc from pr_misc)
to
set @discinc = (select TOP 1 Approved_Disc_Inc from pr_misc)
0
 
obichamAuthor Commented:
This is indeed where I was going wrong.

Thanks very much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.