Link to home
Start Free TrialLog in
Avatar of obicham
obicham

asked on

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??
Avatar of Otana
Otana

you have declared your output variable (@result4) as an integer, therefore you will not get any decimalplaces returned.

try this: @return4 numeric(13,10)
I meant @result4 off course, sorry...
Avatar of obicham

ASKER

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
set @discinc = (select Approved_Disc_Inc from pr_misc)

what type of field is Approved_Disc_Inc? And what does it contain?
Avatar of obicham

ASKER

It is decimal(5) and it contains the value 1.75
select Approved_Disc_Inc from pr_misc

does this return a single value? or multiple records? can you post more of your stored procedure?
ASKER CERTIFIED SOLUTION
Avatar of John844
John844

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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)
Avatar of obicham

ASKER

This is indeed where I was going wrong.

Thanks very much.